Reputation: 4084
I want http://my_domain.com/forum/index.php/blah_blah_blah
to not being redirected to anywhere.
But I want http://my_domain.com/something_else_that_is_not_forum/blah_blah_blah
to be redirected to http://my_domain.com/index.php/something_else_that_is_not_forum/blah_blah_blah
So basically, only everything without http://my_domain.com/forum/
prefix should be redirected.
I have this .htaccess
:
<IfModule mod_rewrite.c>
# Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteRule ^(?!forum.*)(.*)$ index.php/$2 [L,QSA]
</IfModule>
I think the regex should do exactly what I want, but in this case, seems that I'm wrong. http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;df105e678e9b=e1a979a0631bd203b6794debc16ceced
Does anybody know how to do that correctly?
EDIT: I use this
<IfModule mod_rewrite.c>
# Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^\/forum
RewriteRule (?!^forum(?:/.*|)$)^(.*)$ /index.php/$1 [L,NC,QSA]
</IfModule>
That roughly say:
If request is not pointed to file or directory or symbolic link, and it is not /forum
then
If it is not started with forum, then point to /index.php/url.
It seems to be logical (well, we don't need RewriteCond %{REQUEST_URI} !^\/forum
actually), but it still failed when accessing this url: http://www.getnocms.com/forum/index.php?action=admin;area=manageboards;sa=newcat;a5272d5=2fcf142818fc9df2aabb1364942a1d14
Maybe rewrite rule doesn't work with semicolon? I'm not sure.
Upvotes: 3
Views: 272
Reputation: 785156
Your rules are almost correct but some minor changes are needed. Replace your code with this:
<IfModule mod_rewrite.c>
# Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteBase /
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule (?!^forum(?:/.*|)$)^(.*)$ /index.php/$1 [L,NC]
</IfModule>
Upvotes: 1
Reputation: 4136
You could also try:
RewriteCond %{REQUEST_URI} !^/forum
RewriteRule ^(.)$ http://domain.com/$1
Upvotes: 0
Reputation: 4136
RewriteRule !^forum/ index.php/something_else_that_is_not_forum/blah_blah_blah
Anything that doesn't begin with...
Upvotes: 1