HTACCESS - can you set two rules? ending in / and not ?
Moderator: General Moderators
Re: HTACCESS - can you set two rules? ending in / and not ?
Same way you'd do normal URL rewriting except using a [R=301].
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
Sorry I really don't know.
Trust me, if I knew, I'd have done it.
Trust me, if I knew, I'd have done it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: HTACCESS - can you set two rules? ending in / and not ?
You've been doing them all along...
I gave you something quite close: change it so it substitutes an actual URL you want to use (rather than the "-" which means leave it unchanged) and use [R=301] to make it redirect externally rather than rewrite internally.
Code: Select all
DirectoryIndex index.php index.html index.htm
order allow,deny
allow from all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^categ/([0-9]+)/([^/]+) /index.php?page=categ&c=$1&cname=$2&menu=sub [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.php?page=home&menu=home [L]-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
Ok look, I've no idea.
I have tried so many things to point it to a URL and it never seems to work.
I was going to offer some suggestions, but on checking your 401 version, I cannot see how to point it to another URL.
IE.
This doesn't work.
I have tried so many things to point it to a URL and it never seems to work.
I was going to offer some suggestions, but on checking your 401 version, I cannot see how to point it to another URL.
IE.
Code: Select all
RewriteRule ^selector/ /error [L]Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: HTACCESS - can you set two rules? ending in / and not ?
That's it. But you still have to include the [R=301] that I've mentioned a few times now.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
Sorry? So that line is correct - but if it is, why do I need 301 as well?
Incidentally, if the URL is still too long, it fails. So I guess I need something that stops that.
ie.: /selector&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred
If someone spams us with that, it logs an error.
Incidentally, if the URL is still too long, it fails. So I guess I need something that stops that.
ie.: /selector&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred&catname=fred
If someone spams us with that, it logs an error.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: HTACCESS - can you set two rules? ending in / and not ?
[R] tells mod_rewrite to change its usual behavior of just rewriting the URL internally (so Apache looks for files somewhere else) without doing any kind of redirection for the user. Typically [R] is for redirecting only, like using the 301, 302, or 307 HTTP status codes, but you can actually make it send any status code you want - 404, 500, whatever.
I guess that error happens before mod_rewrite can act. I don't know off the top of my head any way to prevent that from logging so I'd just Google the error message.
I guess that error happens before mod_rewrite can act. I don't know off the top of my head any way to prevent that from logging so I'd just Google the error message.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
I have - didn't get a good idea of the issue, so came here to ask experts.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: HTACCESS - can you set two rules? ending in / and not ?
I'm not seeing any way you can work around it, which I'm not too surprised about because typically these things are caused by faulty redirections.
I'd just let it go. You're aware of the problem, and Google is getting non-200s (403s I bet) so they'll stop hitting the pages eventually.
I'd just let it go. You're aware of the problem, and Google is getting non-200s (403s I bet) so they'll stop hitting the pages eventually.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
So...
I assume Google therefore won't see it, and this won't cause anything in the Error Logs?
We'd love to point them to our personal error page, which is ..../error.
But if that cannot be done.....
This is accepting for this page is it?Forbidden
You do not have permission to access this document.
I assume Google therefore won't see it, and this won't cause anything in the Error Logs?
We'd love to point them to our personal error page, which is ..../error.
But if that cannot be done.....
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
Sadly we are still getting these in our error logs....(36)File name too long: access to /selector&catname...
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: HTACCESS - can you set two rules? ending in / and not ?
Right. You'll keep getting them until Google stops crawling the pages. Which it should because it doesn't keep pages that 403.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: HTACCESS - can you set two rules? ending in / and not ?
Gotchya.
I'd like to know why it's crawling pages that don't even exist tho - and haven't existed for over a year.
Though perhaps people are posting out URLs that don't exist, just to spam us, hoping Google will try it on.
So there is no way to take users to a custom page like /error, if a "Filename is too long" ?
I'd like to know why it's crawling pages that don't even exist tho - and haven't existed for over a year.
Though perhaps people are posting out URLs that don't exist, just to spam us, hoping Google will try it on.
So there is no way to take users to a custom page like /error, if a "Filename is too long" ?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: HTACCESS - can you set two rules? ending in / and not ?
An ErrorDocument for 403 should take care of that.
Hmm... Maybe you can make that be a PHP script that does a
to hopefully "override" the 403.
And there's also their Webmaster Tools. You can probably get that URL (or /selector* URLs) removed from the list. And on that note, try adding it to a robots.txt too.
Hmm... Maybe you can make that be a PHP script that does a
Code: Select all
header("HTTP/1.1 404 Not Found");And there's also their Webmaster Tools. You can probably get that URL (or /selector* URLs) removed from the list. And on that note, try adding it to a robots.txt too.