Jump to content

.htaccess Problems Here, Too..


chibineku

Recommended Posts

I have a page called category.php5 that uses $_GET["category"] to fetch the right content from the database. I want to pretty it up so is looks like:sinaesthesia.co.uk/category/psoriasiswhich would equal:sinaesthesia.co.uk/category.php5?category=psoriasisI have successfully done this sort of rewriting before, but since I can't get it to work now, I'm worred that I might have rules in place that are somehow screwing me. Here is my entire .htaccess file - the last couple of lines are supposed to do the above rewrite:

RewriteEngine On#remember to change this to aromaclearRewriteCond %{HTTP_HOST} !^sinaesthesia\.co.uk$ [NC]RewriteRule ^(.*)$ http://sinaesthesia.co.uk/$1 [R=301,L]#Translate default page to rootRewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|html)\ HTTPRewriteRule ^(.*)index\.(php5|html)$ /$1 [R=301,L]#translate any .html ending into .php5RewriteRule ^(.*)\.html$ /$1\.php5#change / for ?RewriteRule ^(.*)\.html/(.*)$ /$1\.html?$2#strip .html from search res pageRewriteRule ^(.*)search/(.*)$ /$1search_results\.html/search=$2#translate product details link from search res pageRewriteRule ^products/(.*)/(.*)/(.*)$ /product_details.php5?category=$1&title=$2&id=$3 [L]#Translate products/psorisis/chamomile-skin-cream-P[x] to productview.php5?id=1RewriteRule ^products/.*-P([0-9]+) /productview.php5?id=$1 [L]#Translate /category/psoriasis to /category.php5?category=$1RewriteRule ^category/(.*) /category.php5?category=$1 [L]

When I manually enter category.php5/category=psoriasis, it works great. When I enter category.php5/category/psoriasis, it doesn't. I'm worried that my line that changes a html/ to html? is an error, however when I take that line out, it still doesn't work. Everything else works as expected.

Link to comment
Share on other sites

54 views and no clues?

Link to comment
Share on other sites

I stripped the file down to just RewriteEngine On#Translate /category/psoriasis to /category.php5?category=psoriasisRewriteRule ^(.+)category/(.+)$ /$1category.php5?category=$2 [L]and it still doesn't work. It's such a simple rewrite, I don't understand why it won't work.

Link to comment
Share on other sites

Hm...that doesn't seem entirely applicable...I understand, but it isn't really what I want to do here. I only have one parameter, for a start.

Link to comment
Share on other sites

Have triedRewriteRule ^(.*)category/([a-z]+)$ /$1category.php5?category=$2 [L]and still nothing - even with that as my only rule. Wtfunk?

Link to comment
Share on other sites

Maybe the search is being greedy, try this instead: ... (.*?)category ...Though I'm not sure, I think greedy searches do stop at the last occurence of the next character in the expression.

Link to comment
Share on other sites

Hm, (.*) does usually eat up any characters. When I try (.*?) I get a 500 Error. Given that I want:sinaesthesia.co.uk/category/psoriasisand the document is at root, I shouldn't even need to worry about capturing the domain and the forward slash, but I've tried it both ways with no success. It's driving me bonkers because it should have been the 2 seconds work I thought it was.

Link to comment
Share on other sites

Ah, I think I got the problem: the server tries to resolve /category/psoriasis into /category.php5/psoriasis because it finds a file called category.php5 - works fine if I use /cat/psoriasis...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...