I'm trying to create clean URLs and so far I've managed to use .htaccess to convert the following URL:
http://www.example.com/index.php?cat...on1&page=Page1
into:
www.example.com/Section1/Page1/
The problem is then getting PHP to interpret the URL and extract the variables. Here's the code I'm using:
.htaccess code:
Expand|Select|Wrap|Line Numbers
- Options +FollowSymLinks
- Options +Indexes
- RewriteEngine on
- #INTERNAL STATIC URL TO DYNAMIC URL
- RewriteRule ^/([^/]+)/?$ /index.php?c=$1 [L]
- RewriteRule ^/([^/]+)/([^/]+)/?$ /index.php?c=$1&p=$2 [L]
- #EXTERNAL DYNAMIC URL TO STATIC URL
- RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9]{1,3}\ /index\.php\?catagory=([^&]+)\ HTTP/
- RewriteRule ^index\.php$ http://www.example.com/%1/? [R=301,L]
- RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9]{1,3}\ /index\.php\?catagroy=([^&]+)&page=([^&]+)\ HTTP/
- RewriteRule ^index\.php$ http://www.example.com/%1/%2/? [R=301,L]
Expand|Select|Wrap|Line Numbers
- $urlVariables = explode("/",$_SERVER['REQUEST_URI']);
- $catagory = $urlVariables[1];
- $page = $urlVariables[2];
Expand|Select|Wrap|Line Numbers
- RewriteRule ^index\.php$ http://www.example.com/index.php/%1/? [R=301,L]
Any suggestions to what I'm missing here?
Many thanks