I have a website that has the following page:
http://www.mywebsite.com/our-services
Which can also have url parameters to vary what is shown
http://www.mywebsite.com/our-services?grade=1093 // 1093 = medium)
http://www.mywebsite.com/our-services?grade=2890 // 2890 = high)
http://www.mywebsite.com/our-services?grade=2890&p=2 // p = page
I want to now be able to have these as seo-friendly/tidy urls but not have a 301 redirect. Ideally i'd like the urls above as an example to become:
http://www.mywebsite.com/our-services/medium-services
http://www.mywebsite.com/our-services/high-services
http://www.mywebsite.com/our-services/high-services/page-2
Is this possible using htaccess? Am I right in thinking internal redirects with htaccess can achieve this without a redirect for the user? Looking on here I have found this post which is along the same lines but it is slightly different. Also when I try that example ie:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /ucp/profile\.php?([^=]+)=(\S+) [NC]
RewriteRule ^ucp/profile\.php$ /ucp/%1/%2? [R=301,L,NC]
# Now, deal with internal rewrites (which will not cause redirection):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ucp/([^/]+)/([^/]+)/?$ /ucp/profile.php?$1=$2 [NC,L]
When i've tested that in a dummy page when I go to:
mysite.com/ucp/profile.php?player=Heartfire
It gives me the following page:
mysite.com/ucp/?player/Heartfire%3f
It should be:
mysite.com/ucp/profile/heartfire
Your first RewriteCond
needs tweaking to escape ?
:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /ucp/profile\.php\?([^=]+)=(\S+) [NC]
RewriteRule ^ /ucp/%1/%2? [R=301,L,NC,NE]
# Now, deal with internal rewrites (which will not cause redirection):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ucp/([^/]+)/([^/]+)/?$ ucp/profile.php?$1=$2 [NC,L,QSA]
# new rules for /our-services/...
RewriteRule ^(our-services)/high-\w+/?$ $1?grade=2890 [L,NC,QSA]
RewriteRule ^(our-services)/high-\w+/page-(\d+)/?$ $1?grade=2890&p=$2 [L,NC,QSA]
RewriteRule ^(our-services)/medium-\w+/?$ $1?grade=1093 [L,NC,QSA]
RewriteRule ^(our-services)/medium-\w+/page-(\d+)/?$ $1?grade=1093&p=$2 [L,NC,QSA]
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.