0

I'm running Windows 7 xampp server it has Apache and it has lines that are needed to uncomment to work fine.

However when I try to use RewriteRule I bump into the problem.

When I write wrong code at the start of htaccess it throws error 500, there are few commands that works, but when I use RewriteRule it simply ignore that part , unless if I write something syntax wise wrong then it reacts as error, but i have never seen my link changed.

.htaccess file is placed at myDomain directory

Can it possibly be issue of software or it's my code?

I have this dynamic link:

http://localhost//myDomain/folder/ad.php?title=theTitle&id=1

and I need to get this:

http://localhost//myDomain/folder/theTitle/1

My htaccess file looks like this:

RewriteEngine on
RewriteBase /myDomain/folder
RewriteCond %{REQUEST_URI} ^/ad.php$ [NC]
RewriteCond %{QUERY_STRING} ^title=(.*)&id=(.*)$
RewriteRule (.*) http://localhost/myDomain/folder/%1/%2.aspx? [R=301,L]

Any help would be highly honored :)

deceze
  • 510,633
  • 85
  • 743
  • 889

1 Answers1

0

You can have these rules in /myDomain/folder/.htaccess:

RewriteEngine on
RewriteBase /myDomain/folder/

RewriteCond %{THE_REQUEST} /ad\.php\?title=([^\s&]+)&id=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L]

RewriteRule ^([^/.]+)/([0-9]+)/?$ ad.php?title=$1&id=$2 [L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • 1
    I will find you, and I will give you a cookie :) – Lukas Katilauskas Aug 18 '14 at 12:05
  • Small issue fallowed up styles that was included into ad.php does not work now when I include it as separate file it does not even compile it, throws out code as it's writen – Lukas Katilauskas Aug 18 '14 at 12:13
  • For css/js etc just use absolute path in your css, js, images files rather than a relative one. Which means you have to make sure path of these files start either with `http://` or a slash `/`. You can try adding this in your page's HTML header: `` so that every relative URL is resolved from that URL and not the current URL. – anubhava Aug 18 '14 at 13:31