Reputation: 1068
I am trying to make pretty links using .htaccess. I am new to apache and can't really figure out why it is not working.
I have two pages:
single_picture.php
and single_video.php
Both pages take two arguments : name, and cat_id/category_id
Here are two examples: http://www.unclelol.com/single_picture.php?name=Real-time-images-5&cat_id=13
http://www.unclelol.com/single_video.php?name=football%20fail&category_id=22
And here is my .htaccess
:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^pictures/([A-Za-z0-9\-_]+)/([A-Za-z0-9\-_]+)/?$ /single_picture.php?name=$2&cat_id=$1
RewriteRule ^videos/([A-Za-z0-9\-_]+)/([A-Za-z0-9\-_]+)/?$ /single_video.php?name=$2&category_id=$1
Now for reasons unknown . The rewrite for pictures works perfectly:
http://www.unclelol.com/pictures/13/Real-time-images-5/
But the rewrite for videos gives 404 error:
http://www.unclelol.com/videos/22/football%20fail
Any help will be greatly appreciated.
Ahmar
Upvotes: 0
Views: 136
Reputation: 10132
Merge your both rules to single:
RewriteRule ^(.+)s(?=/)/([^/]+)/([^/]+)/?$ /single_$1.php?name=$3&cat_id=$2 [NE,L]
Also remove the pattern ([A-Za-z0-9\-_]+)
which will not work for %20
as you have in your video url. Instead use ([^/]+)
which matches any character until reaches /
.
Upvotes: 1