raymond_feliciano Posted April 9, 2012 Share Posted April 9, 2012 I am new to SEO urls and I have been reading on mod-rewrite and seo urls so I decided to implement this on my site. I am trying to rewrite http://mysite.com/index.php?page_id=1 So I created a .htaccess file and dumped it in the root of my site and add these lines Options +FollowSymlinks RewriteEngine On RewriteRule ^index/([0-9]+)\.html$ index.php?page_id=$1 But it seems that I am doing something wrong because it does not rewrite the url. Is there something that I need to add in my index.php page or is my rule wrtten wrongI have been working on this for about 8 hrs with no luck. any suggestions would be appricated. Quote Link to comment Share on other sites More sharing options...
scootstah Posted April 9, 2012 Share Posted April 9, 2012 It doesn't look like there is a problem. What do you mean it "does not rewrite the URL"? What happens when you go to index/1.html? Quote Link to comment Share on other sites More sharing options...
raymond_feliciano Posted April 9, 2012 Author Share Posted April 9, 2012 I am new so I figured it would display the rewritten url in the address bar. When I navigated to that url I get the page but the css is gone. How would I get the new url to display and keep the css intact. Thanks for your help I really do appricate it Quote Link to comment Share on other sites More sharing options...
scootstah Posted April 9, 2012 Share Posted April 9, 2012 It doesn't change the existing URL's to new pretty URL's, it just points the pretty URL to the existing URL. As for the CSS, you'll need a flag that allows real files to be exempt from the re-write. I bet your CSS URL is being re-written to the pretty URL and thus it doesn't exist. Try this: Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index/([0-9]+)\.html$ index.php?page_id=$1 [L] This will exclude directories and files from being re-written. Quote Link to comment Share on other sites More sharing options...
raymond_feliciano Posted April 10, 2012 Author Share Posted April 10, 2012 Thanks for your advice it helped me out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.