views:

43

answers:

2

How do I rewrite this rule to redirect everything back to the index or server_root?

If there is a request for say, www.site.com/articles/some-article.php, the somearticle.php should be re-routed back to the index page. I also don't want to have the url showing the "index" portion of the URL. site.com/index is where everything should be at.

RewriteRule ^(.*)$ index.php?dk=$1 [L,QSA]

OK, I see now what is happening and I think it may help someone to help me better. With my rule, exactly as it is above in my example, I can get the following back into my index.php file with no problems.

http://site.com/index/somethin/else/here/test.php

Here is what I need: I need to remove the index portion of the url. This url should be rewritten as: http://site.com/somethin/else/here/test.php

I hope this helps.

A: 

The Rewirite would pass the url to be www.site.com/index.php?dk=articles/some-article.php is that what you are after?

RewriteRule ^/articles/(.*)$ index.php?dk=$1 [L,QSA] This should give you www.site.com/index.php?dk=some-article.php

RewriteRule ^/articles/(.*).php$ index.php?dk=$1 [L,QSA] Gives you www.site.com/index.php?dk=some-article

Or do you want this? www.site.com/?dk=some-article

ontangent
jim
A: 
RewriteRule ^.*/(.*)$ /?dk=$1 [L,QSA]

...if you only want to pass it the file name, or...

RewriteRule ^(.*)$ /?dk=$1 [L,QSA]

...if you want the full path

Christian M. M.
Hi Christian, thanks for the answer. Unfortunately, neither of these work and I just don't have enough experience with rewrite to figure out why... Would you know why the full path isn't rewritten?
jim
All Im getting is page not found.
jim