简体   繁体   中英

htaccess seo friendly urls, mod rewrite, redirection

I'm currently trying to make SEO friendly URL's for very specific URL's, not all of them. I've been at this for 48 hours with no luck. My goal is to make http://mydomain.com/index.php?p=g&id=1 look like this; http://mydomain.com/pageone/ - so far I have been able to achieve the redirection thusfar, but it is showing a 404 "The requested URL /pageone/ was not found on this server". My question is how to make it redirect to the virtual directory and not throw a 404.

Please note I want to add a rule for each page id, not a rule that changes everything from index.php?p=g&id=, just each specific link.

Below is my htaccess code:

Options +FollowSymLinks
Options -Multiviews
RewriteOptions MaxRedirects=1
RewriteEngine On 
RewriteCond %{QUERY_STRING}  ^p=g&id=1$ [NC]
RewriteRule ^index\.php$ /pageone/? [r=301,nc]

Any help with this would be GREATLY appreciated.

You redirected the index.php to /pageone/ but did not define what /pageone/ will actually show. You should add the following line to your .htaccess :

RewriteRule ^pageone/?$ index.php?p=g&id=1 [L]

and remove your rule. If you want to keep both RewriteRule s, then add the following lines right after RewriteEngine On :

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM