0

I want to change dynamic URL's to URL's more acceptable by search engines.
For example change this :

http://myurl.com.au/page.php?id=100&name=myname

to

http://myurl.com.au/100/myname.php

or .html at the end it does not matter.

I am using Apache 2.2. I am not using .htaccess rather I put my code in /etc/httpd/conf/vhosts/myfile but it does not work, the URL does not change at all.

Options Indexes Includes +FollowSymLinks
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.php$ /page.php?id=$1&name=$2 [L]

What am I doing wrong?

Hussain
  • 4,349
  • 5
  • 38
  • 63
tuberider
  • 114
  • 9
  • possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – deceze Dec 13 '13 at 10:11

2 Answers2

0

Either your have the wrong description in your question or your rule is backwards. Maybe this could work:

Options Indexes Includes +FollowSymLinks
RewriteEngine On    
RewriteCond %{QUERY_STRING} id=(.*)&name=(.*)$
RewriteRule ^/page\.php /%1/%2.php [L]
Qben
  • 2,559
  • 2
  • 23
  • 32
  • Thank you for your response. I tried your code and it does not work either, the URL does not change after refreshing browser. The RewriteRule that I have I got from a mod_rewrite generator website [link](http://www.generateit.net/). Also I do not understand what you mean by me having the wrong description in my question, what is wrong with it? – tuberider Dec 15 '13 at 23:06
  • Your rule is trying to rewrite http://myurl.com.au/100/myname.php to http://myurl.com.au/page.php?id=100&name=myname. In your question you say you want to do the opposite. – Qben Dec 16 '13 at 08:39
  • If it's not changing I guess you could try the `R` flag. Also, enabling logging is a good thing when troubleshooting `mod_rewrite`. – Qben Dec 16 '13 at 14:23
  • Qben you are absolutely right, I think I had a small brain freeze. I later realised everything and it is now working as expected for me. Thank you for your help. – tuberider Dec 16 '13 at 22:43
  • You might want to answer your own question, and accept the answer for future references. :) – Qben Dec 17 '13 at 06:28
0

After doing some further testing it turns out that I do have the right code. I just don't have my head screwed on and was not thinking. Expecting that the mod_rewrite would magically change the URL to symbolic links when it is actually doing the reverse of that. It is all working for me now.

tuberider
  • 114
  • 9