Mod_Rewrite With Two Extension Variables
Posted: Fri Jun 17, 2011 10:36 pm
Hi,
I know this has been written about before however after trawling the forum I have been unable to find a definitive answer so was hoping someone might be able to help out.
Essentially I would like to find a way to convert two variables to pretty url form using mod_rewrite. Sorry if I am not explaining this very well but I am very new to url rewriting.
At present I have pretty url's running nicely using mod_rewrite in the config file and the following htaccess file,
What I would like to do is find a way to add a second variable to the rewrite rule so that instead of having, for example:
http://www.mywebsite.com/about-me&variable=chris
I can have:
http://www.mywebsite.com/about-me/chris
I am using $smarty.get.variable to grab the information from the url which works great however it would be even better if I could clean up the URL too.
If anyone can point me in the right direction that would be terrific as I have tried countless combinations in the htaccess file without any success.
Also, please let me know if what I am trying to achieve is not possible.
Many Thanks
Chris
I know this has been written about before however after trawling the forum I have been unable to find a definitive answer so was hoping someone might be able to help out.
Essentially I would like to find a way to convert two variables to pretty url form using mod_rewrite. Sorry if I am not explaining this very well but I am very new to url rewriting.
At present I have pretty url's running nicely using mod_rewrite in the config file and the following htaccess file,
Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# except for form POSTS
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
http://www.mywebsite.com/about-me&variable=chris
I can have:
http://www.mywebsite.com/about-me/chris
I am using $smarty.get.variable to grab the information from the url which works great however it would be even better if I could clean up the URL too.
If anyone can point me in the right direction that would be terrific as I have tried countless combinations in the htaccess file without any success.
Also, please let me know if what I am trying to achieve is not possible.
Many Thanks
Chris