Forum Moderators: phranque
In other words, the below address works fine.
http://example.com/abc/
While the one below gives me a "Bad Request - Error 400"
http://example.com/abc
If I delete the .htaccess file in the subdirectory (abc), URL's without trailing slashes work just fine so I'm sure there's something missing in the .htaccess file.
This is how my .htaccess looks:
RewriteEngine on
RewriteRule (.*).html index.php?page=$1 [L]
This .htaccess file works just fine with XAMPP. (Windows)
Does anyone know what may be missing?
Best Regards,
Daniel
My sub directory URL is accessible & indexed as www.example.com/xyz/
But I would like search engines to access it as www.example.com/xyz/index.html which I don't know how to resolve it.
2) I would like to do 301 redirect www.example.com/xyz/ to www.example.com/xyz/index.html
We are hosted on GD on linux servers. I've this problem with couple of sub directories but others are fine. Could someone please tell me how can I over come this issue.
Thanks!
K
The redirect you're asking about is a simple matter, but almost everyone here would advise you to have search engines index /xyz/ and not index /xyz/index.html
There is no reason to waste the bandwidth needed to transmit those extra characters or to make your URLs longer and more complex (and ugly in the search results) by adding "index.whatever" when it is not needed. If you advertise on radio, TV, or in print, these longer URLs are harder to say, harder to 'hear' correctly, and harder to read as well...
If you 'change' the URL, your index page will lose its search ranking for a period of time ranging from weeks to months -- up to a year. It will eventually come back after the search engines have re-indexed your site several times and have 'figured out' that you have moved the page and want to pass the 'ranking power' from the old to the new URL. The time required depends on how often your site is spidered and what the rankings of all pages pointing to your index page are, so it's not predictable. But it is something to consider seriously: Can your business withstand having those pages dropped from the search results for weeks to months?
Plus, consider what happens if you change your site to .php, .cfm, or .asp in the future... Using "/" would prevent you from having to make any changes at all, except maybe to your DirectoryIndex directive; No redirects would be required.
So all I can say is that what you want to do is ill-advised, but if you insist, you should be able to work out the solution by looking at the first few examples in the Apache URL Rewriting Guide.
Jim
This would really help me.
I actually tried to use this lines in .htaccess file and uploading it in xyz sub directory:
DirectoryIndex index.html
permanent redirect /xyz/ http://www.example.com/xyz/index.html
After making this changes when I access our site just with
www.example.com/xyz/ it gives a message saying it has put the redirect in a loop and cannot resolve.
It would be great if you could me help me in here. At the moment we don't have any PR but yes we do have ranking for just one keyword which we are fine to invest in a 2-3 months to see the new results with the indexing behavior of search engines to figure out that now the page will be /xyz/index.html
Your feedback will be much appreciated.
Cheers!
Redirect Permanent /xyz/[i]<anything-at-all-here-including-index.html>[/i] http://www.example.com/xyz/index.html You need to use RedirectMatch, which uses regular-expressions pattern-matching instead of prefix-matching, and so is more precise:
RedirectMatch 301 ^/xyz/$ http://www.example.com/xyz/index.html I have warned you strongly that doing this is a mistake that you will likely regret later. It would be far better to change the "/index.html" links to point to "/" now and to install a 301 redirect from "/index.html" to "/" to catch the 'straggler links' so as to be better-off in the future, rather than taking the short-sighted approach of linking and redirecting to "/index.html" just because you currently have more links to that URL than to "/".
Let me ask, when you want to search, do you go to www.google.com/ or to www.google.com/index.py?
We get far, far more requests here for help getting rid of "/index.html" by redirecting it to "/" than we get for the opposite, and that in itself should tell you something. However, the solution above will do what you claim to want to do, if not what you should do.
Best of luck,
Jim
Thank you for your reply.
Sorry for the late answer.
> What version of Apache is used on you GD server?
Apache/1.3.33
> What do you see in your server error log file?
I've looked around my 'control panel' but I can't seem to find any logs at all. If I read the help section correctly deluxe/unlimited users get log access while we economy users are left with nothing ;)
I did solve the trailing slash problem by adding the following to a .htaccess file in the 'abc' subdirectory.
Whether there is a better solution or not is beyond my understanding. If anyone knows, I'm all ears..
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} (.*)
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.+[^/])$ %1/ [R=301,L]
RewriteRule ^(([^/]+/)*[^./]+)$ http://www.example.com/$1/ [R=301,L]
It also specifies a canonical URL as the redirect target so that you won't have a problem with UseCanonicalName if the server config is inconsistent with your actual preferences -- e.g. "www" vs. "non-www" domain.
If you find yourself tempted to make use of additional mod_rewrite or scripting on your site, it is time to move to a 'real' host. These can still be had for less than $10 U.S. per month, and any site worth keeping on-line is certainly worth 33 pennies per day... Log files are not optional, IMHO. Lacking that critical info at the wrong time might easily put you out of business.
Jim