Htaccess base code not working

It really upsets for me that I tried to get this basic htaccess rework while working with the clock, but couldn't do it.

I have tried the following.

Options +FollowSymlinks RewriteEngine On RewriteBase /funshoppie/ ############ Details page ################ RewriteCond %{THE_REQUEST} Deal\-details\.php\?title\=([A-Za-z0-9-]+)&id=(\d+) [NC] RewriteRule ^%1%2? [R=301,L,NE] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^Deals/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ Deal-details.php?title=$1&id=$2 [NC,QSA,L] 

can someone tell me what i'm doing badly?

url I'm trying to rewrite

 http://localhost/funshoppie/Deal-details.php?title=Styling%20Tools%20-%2020%%20off&id=7 

what I wish after success

 http://localhost/funshoppie/Deals/Styling-Tools-20%-off/7 

I checked the error logs, httpconf and provided uncommented rewrite_module. I do not know what causes this error.

+6
source share
2 answers

I cannot try this at the moment, but your regular expression does not match the url:

Bargain-details.php name = Styling% 20Tools% 20-% 2020%% 20off &? ID = 7

Based on en- and decoding, these can be the following two lines:

  • ?
  • Transaction-details.php name = Styling% 20Tools% 20-% 2020%% 20off & ID = 7
  • Deal-details.php? title = Styling Tools - 20% off & id = 7

In no case does it match your expression:

[..] Deal-details.php \? title \ = ([A-Za-z0-9 -] +) & id = (\ d +) [..]

You are missing the characters represented in your expressions, for example:

  • "%"
  • "" (space)

Try the following expression:

 Deal\-details\.php\?title\=(.+)&id=(\d+) 

This will match any type of title. Otherwise, I see no problem.

+5
source

Finally, I realized this on my own, I believe.

In the last rewrite rule, there were some problems with the slash due to the fact that they did not do what was intended. Next, I rewrote all existing and future URLs through some pure url function and used these pretty statements in the URL. Then it worked!

 RewriteCond %{THE_REQUEST} Deal\-details\.php\?title\=([A-Za-z0-9-_]+)&id\=(\d+) [NC] RewriteRule ^ %1/%2? [R=301,L,NE] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([A-Za-z0-9-_]+)/(\d+)$ Deal-details.php?title=$1&id=$2 [NC,QSA,L] 

It worked for me.

-one
source

All Articles