Forum Moderators: phranque
I have no problem being able to have my sites do either along with redirects from either or, I'm simply curious what if any preference the search engines have.
- John
A URL ending with a slash indicates a directory listing of files or a directory index page, i.e the "home page of a directory".
A URL not ending with a slash indicates a resource -- a page, for example.
Other than that, SEs don't care, so there's no reason to make your URL longer by adding a slash.
Jim
If and only if the URL resolves to a directory or directory index, in which case, it should have a slash to begin with.
example.com/foo refers to the page called "foo"
example.com/foo/ refers to the file listing for the subdirectory "/foo", or to the index page located in the subdirectory "/foo".
Jim
One odd thing I noticed was that with the new version of my site if I don't have a directory in the file system it would not rewrite example.com/music to example.com/music/ while if the directory exists (even if empty) it will.
Is there a way I can modify my Apache script in .htaccess to not require empty directories for that?
- John
RewriteEngine on
RewriteRule !\.(css圭ur圯xe夙if夙z多tml多3m夷co夸pg夸s妃ov妃p3妃p4妃si如df如l如ng字ar存wf宇tf宇xt安mv寺html寺ml寺pi屹ip)$ index.php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^index\.php$ [%{SERVER_NAME}...] [NC,R=301,L]
Unrelated observation: Your first rule above is missing the [L] flag, and the second rule above is missing the trailing slash on the redirect URL following "%{SERVERNAME}". This will invoke an additional mod_dir redirect.
Also, if you want ro use [NC] on the second rule, you'll have to use it on the second rule's RewriteCond as well, otherwise having the [NC] flag on the rule won't accomplish anything.
Jim
I removed NC, all the file paths are case sensitive to begin with so not sure why I had it.
I've updated my script (is that what Apache's syntax is technically referred to as?) so here are the changes. Thanks for your help and everyone's input!
- John
RewriteEngine on
RewriteRule !\.(css圭ur圯xe夙if夙z多tml多3m夷co夸pg夸s妃ov妃p3妃p4妃si如df如l如ng字ar存wf宇tf宇xt安mv寺html寺ml寺pi屹ip)$ index.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^index\.php$ [%{SERVER_NAME}...] [R=301,L]