logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Rewrite problems
Author
Janooo



Joined: 08 Feb 2025
Posts: 1
Location: Canada, Toronto

PostPosted: Sat 08 Feb '25 17:17    Post subject: Rewrite problems Reply with quote

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: 7397
Location: EU, Germany, Next to Hamburg

PostPosted: Mon 10 Feb '25 17:38    Post subject: Reply with quote

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


Reply to topic   Topic: Rewrite problems View previous topic :: View next topic
Post new topic   Forum Index -> Apache