Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine On
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update YourMamboDirectory (just / for root)
RewriteBase /
#
# Rules
#
# append "/" if requested URI contains no filetype and does not end in "/"
#
RedirectMatch permanent ^/mambo$ [mysite.com...]
#
#if no www then add it
RewriteCond %{HTTP_HOST}!^www\.mysite\.com
RewriteRule (.*) [mysite.com...] [L,R=301]
#
# if requested URI does not exist as a file
RewriteCond %{REQUEST_FILENAME}!-f
# and if requested URI does not exist as a directory
RewriteCond %{REQUEST_FILENAME}!-d
# then rewrite <anything> to index.php and stop processing rules for this pass
RewriteRule ^(.*) index.php
I have tried adding things like:
#RewriteCond %{REQUEST_URI}!(\.¦/$)
#RewriteRule (.+) [mysite.com...] [R=301,L]
but it doesn't seem to work wherever I put it. Can anyone help me with this crazy issue? jdmorgan seems to know alot about this... :) ;)
Welcome to WebmasterWorld!
I looked at your code several times, but other than the misplaced comments and a possible problem with the order of the rules, I don't see much wrong. I'm wondering if you fell into a common trap here -- this forum deletes spaces and changes a few characters. I have fixed everything I saw that was "non-optimal" and restored the missing spaces. Try this code, but be sure to change the broken pipe "¦" character to a solid pipe before use:
# Redirects using mod_alias
#
RedirectMatch permanent ^/mambo$ http://www.example.com
#
# RewriteRules using mod_rewrite
#
# if no www then add it
RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteRule (.*) http://www.example.com/$1 [L,R=301]
#
# append "/" if requested URI contains no filetype and does not end in "/"
RewriteCond %{REQUEST_URI} !(\.¦/$)
RewriteRule (.+) http://www.example.com/$1/ [R=301,L]
#
# rewrite all requests to index.php, unless requested resource exists
# if URL not already rewritten to index.php
RewriteCond %{REQUEST_URI} !^/index\.php$
# and if requested URI does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and if requested URI does not exist as a directory
RewriteCond %{REQUEST_FILENAME} !-d
# then rewrite <anything> to index.php
RewriteRule (.*) /index.php [L]
This line is working too:
RedirectMatch permanent ^/mambo$ [mysite.com...]
if i go to mysite.com/mambo/* it directs to the page without the mambo.
I have one other rule which I threw in that checks to see if there is a?&=ref at the end of the url and it gets rid of that. That seems to be working to. However, I can't get that ending slash thing working.
So since that other stuff is working does that mean mod-Rewrite is working? It seems like something is fishy since most of the stuff works but the trailing slash code isn't doing anything.
If you have and you still cannot get it to work, I would try to narrow down where the problem is, by removing (or commenting out) all rules except the rule for the trailing /.
Then add them back in the same order as they are in currently one set at a time. I do not see any conflict, or reason for them to not work, but if we isolate each set, we should be able to make sure it functions on its own, and then check to see how it functions with the other rulesets as well --- maybe then we can figure out where it is breaking.
Justin
So, then I took all the rules out except for the trailing slash rule. when I did this, none of my content items would work at all.
So I notice that all the other rules work except this one. It seems weird. But it's really bothering me.
I think i mentioned before that I have sef running in mambo (that is the feature that makes mambo write better url's for search engines). Still, i wouldn't think that would affect this one issue. doh!