Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Rewrite problems |
|
Author |
|
Janooo
Joined: 08 Feb 2025 Posts: 1 Location: Canada, Toronto
|
Posted: Sat 08 Feb '25 17:17 Post subject: Rewrite problems |
|
|
Hi,
I have following lines in my conf file:
RewriteCond %{REQUEST_URI} !/user/login
RewriteCond %{REQUEST_URI} !/contactus
RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
I want to achieve the following:
If the sub-string is NOT '/user/login'
and it is NOT '/contactus' then redirect.
In other words if there is one of these two sub-strings then do not redirect.
That rule fails though. Why?
Any tip is appreciated.
Thank you,
Jano |
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7398 Location: EU, Germany, Next to Hamburg
|
Posted: Mon 10 Feb '25 17:38 Post subject: |
|
|
Hi Jano,
A little bit of regex is needed for the path.
for httpd.conf
Code: |
RewriteCond %{REQUEST_URI} !^/user/login(.*)$
RewriteCond %{REQUEST_URI} !^/contactus(.*)$
RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
|
or set a last rule in htaccess
Code: |
RewriteRule ^/(user/login|contactus) - [L]
RewriteRule ^(.*)$ https://mysite.com/$1 [R=301,L]
|
|
|
Back to top |
|
|
|
|
|
|