Reputation: 5203
So at the moment, any missing pages (404) get redirected to domain.com/search.php and carries the query parameters
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ search.php [QSA,L]
This works great, however, I have an edge case for domain.com/submit where I need it to redirect to domain.com/submit.php
Can't seem to figure out how to do it.
Thanks in advance
Upvotes: 1
Views: 32
Reputation: 41249
You can use this :
RewriteEngine On
RewriteBase /
#rewrite /submit to /submit.php
RewriteRule ^submit/?$ submit.php [L,NC]
#rewrite other non-existent URIs to /search.pho
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ search.php [QSA,L]
Upvotes: 1
Reputation:
Like this, I suggest adding NC so it's case-insensitive:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^submit?$ submit.php [NC, L]
RewriteRule ^(.+)$ search.php [NC, QSA,L]
Upvotes: 1