Home using Mod Rewrite in .htaccess to get "prettify" urls working correctly
Reply: 0

using Mod Rewrite in .htaccess to get "prettify" urls working correctly

user1929 Published in April 22, 2018, 12:53 am

I have a website which has several pages which are generated by pulling data from a database, the links to view those pages look like this.


and i am trying to set up a mod rewrite to get the server to display the the same webpages but using a much nicer looking url.


the line of code i have used in my .htaccess file is

RewriteRule ^article/([0-9]+)/([A-Za-z0-9-\+]+)/?$ /article.php?id=$1&title=$2 [NC,L,QSA]

now when i go back to my website and type in the following url www.mywebsite.com/article/01/title

it displays the correct content but there is no styling attached to the page at all?

my full .htaccess is as follows

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
# Needed before any rewriting
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(default|index)\.   (html|php|htm)\ HTTP/ [NC]
RewriteRule ^(([^/]+/)*)(default|main|index)\.(html|php|htm)$ http://www.example.com/$1 [R=301]
RewriteRule ^article/([0-9]+)/([A-Za-z0-9-\+]+)/?$ /article.php?id=$1&title=$2 [NC,L,QSA]

can someone please tell me what i am doing wrong? many thanks

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304071 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO