Forum Moderators: phranque

Message Too Old, No Replies

help with mod rewrite

         

coolfx35

2:18 pm on Nov 4, 2009 (gmt 0)

10+ Year Member



Hello,

So bascially this is what I needed.

everytime someone goes to

http://www.example.com/XBOX

I want it to go to

http://www.example.com/xbox

Can someone tell me what rule I can use for this?

jdMorgan

4:51 pm on Nov 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post your best-effort code as a basis for discussion.

Please see our Apache Forum Charter for more information.

Thanks,
Jim

coolfx35

5:38 pm on Nov 4, 2009 (gmt 0)

10+ Year Member



Options -MultiViews

<IfModule mod_php4.c>
php_flag register_globals Off
</IfModule>
<IfModule mod_php5.c>
php_flag allow_url_include Off
php_flag register_globals Off
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^XBOX/ http://www.example.com/xbox/ [R=301,L]

---------------

http://www.example.com/XBox/index.php

Will go to

http://www.example.com/xbox/index.php

But

http://www.example.com/XBox/ <-- still says page not found.

I need it to go to

http://www.example.com/xbox/

Thanks.

Note:

RewriteRule ^XBox/ http://www.example.com/xbox/ [R=301,L] <-- this doesn't work neither.

jdMorgan

12:21 am on Nov 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to detect and correct any and all upper- and lowercase 'mixtures', then you'll need something like:

Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteCond %{REQUEST_URI} !^/xbox/$
RewriteRule ^XBOX/$ http://www.example.com/xbox/ [NC,R=301,L]

Using [NC] means the rule pattern always matches, regardless of upper/lowercase.
The RewriteCond is therefore needed to prevent a redirection loop if the requested URL-path is already all-lowercase.

If you want to redirect /XboX/<any-path> to /xbox/<any-path>, then you'll need to back-reference the additional path-part and use:


Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteCond %{REQUEST_URI} !^/xbox/
RewriteRule ^XBOX/(.*)$ http://www.example.com/xbox/$1 [NC,R=301,L]

Jim