Jesper
Jesper

Reputation: 999

mod_rewrite backwards for old dynamic urls

I have mod-rewrite working ok on an apache 2.2, but the problem is that it doesn't work "backwards".

I have these rules that makes SEO friendly urls work:

 RewriteRule ^sjg/([^/]+)/([0-9]+)/?$           /showimage.php?model=$1&image=$2 [L]
 RewriteRule ^sjg/([^/]+)/page/([0-9]+)/?$      /model.php?model=$1&page=$2      [L]
 RewriteRule ^sjg/([^/]+)/?$                    /model.php?model=$1              [L]

But the "old" urls still work i.e. website.com/showimage.php?model=abc&image=123

I would like to rewrite those urls if they are loaded directly or from old links in order to have only one url-scheme working.

Upvotes: 0

Views: 40

Answers (1)

php_nub_qq
php_nub_qq

Reputation: 16017

Assuming you have a page to report errors, 404 in particular, you can add this rule at the end and you should be fine:

RewriteRule ^.*$ __404_PAGE_HERE__

This will redirect all requests that didn't match your previous rules to your 404 page.

Best wishes.

Upvotes: 1

Related Questions