Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

How do I rewrite an incoming URL and then redirect?

$
0
0
Hello everyone.

Is it possible with Nginx to first rewrite an incoming URL, and then redirect the rewritten URL?

Example -

Incoming URL: www.domain.com/directory/index.php?id=2&path=4

Want to rewrite it to: www.domain.com/directory/index2.php?id=2&path=4

Then I want to redirect to /index.php


So any incoming URL that:
a) where index.php is not in the document root (like www.domain.com/index.php)
b) where index.php is in the URL in a sub directory or sub-sub directory (like www.domain.com/test/dir/index.php
c) when rewriting it must include all original URL parameters

Then once index.php is rewritten to index2.php we went to redirect that newly rewritten URL to /index.php. Why?

OK, so here is the thing. I am running Magento. And I want to use the Magento URL rewrite feature. But whenever I try to rewrite an incoming old URL to a new Magento URL that contains index.php I get a 404 page. However if I use index2.php then it redirects just fine! I know it's weird, but I think it has something to do with Magento's internal workings and settings.

Anyway I though If I were to set up Nginx to rewrite and then redirect then I could cheat inside Magento and set as incoming URL www.domain.com/test/index2.php?id=.... and it will redirect just fine. Anyone knows anything?

Thanks,

Martin

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>