| Author |
|
mightyaswell Newbie

Joined: 26 January 2012 Location: United States
Online Status: Offline Posts: 5
|
| Posted: 26 January 2012 at 2:12pm | IP Logged
|
|
|
I used to have a ton of pdf files in a directory like
this:
http://www.mysite.com/pubs/xxxxx.pdf
I want to redirect any request for content in the /pubs
directory to a url like /404/?pub=xxxxx.pdf
so
http://www.mysite.com/pubs/xxxxxx.pdf is redirected to:
http://www.mysite.com/404/?pub=xxxxxx.pdf
Possible?
Edited by mightyaswell - 26 January 2012 at 2:12pm
|
| Back to Top |
|
| |
Guests Guest

Joined: 01 October 2003
Online Status: Online Posts: -149
|
| Posted: 27 January 2012 at 5:03am | IP Logged
|
|
|
Hello,
Please, try using:
Code:
RewriteEngine on
RewriteBase /
RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf [NC,R=301,L] |
|
|
Regards
Andrew
|
| Back to Top |
|
| |
mightyaswell Newbie

Joined: 26 January 2012 Location: United States
Online Status: Offline Posts: 5
|
| Posted: 27 January 2012 at 11:26am | IP Logged
|
|
|
Hi Andrew,
The RewriteBase / seems to cause everything to redirect
to my 404
There is actually no /pubs folder (or pdfs) on the
server, they have been removed but old search engines
still have links...
Will the rewrite happen before the 404 error?
Heres my current config file:
Code:
<VirtualHost www.mysite.com>
RewriteEngine On
RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf
[NC,R=301,L]
# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/pubs|^/_devel|)($|/)
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?
\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA]
RewriteCond %{HTTP:User-Agent}
(?:YodaoBot|Yeti|ZmEu|Morfeus\f**king\Scanner) [NC]
RewriteRule .? - [F] RewriteLog Level 9 LogLevel debug
</VirtualHost>
|
|
|
Edited by mightyaswell - 27 January 2012 at 11:26am
|
| Back to Top |
|
| |
Guests Guest

Joined: 01 October 2003
Online Status: Online Posts: -149
|
| Posted: 30 January 2012 at 3:55am | IP Logged
|
|
|
Rewrite occurs first. Please, provide the rewrite.log for the testing request.
Logging issues described in FAQ
Regards
Andrew
|
| Back to Top |
|
| |
mightyaswell Newbie

Joined: 26 January 2012 Location: United States
Online Status: Offline Posts: 5
|
| Posted: 30 January 2012 at 1:30pm | IP Logged
|
|
|
Andrew,
You original code suggestion works, the problem I seem to
have is that request for the root level such as
www.mysite.com does not work when I have the ReWriteBase /
set. There must be a conflict with my content managment's
url system.
|
| Back to Top |
|
| |
Guests Guest

Joined: 01 October 2003
Online Status: Online Posts: -149
|
| Posted: 31 January 2012 at 3:12am | IP Logged
|
|
|
Hello,
'RewriteBase /' itself doesn't do anything. Please, see the documentation.
Please, provide the rewrite.log for the testing request.
Regards
Andrew
|
| Back to Top |
|
| |
mightyaswell Newbie

Joined: 26 January 2012 Location: United States
Online Status: Offline Posts: 5
|
| Posted: 31 January 2012 at 11:46am | IP Logged
|
|
|
Andrew,
No rewritelog entries are created (I have followed the
docs for logging, and error.log is working fine but
indicates no issue)..
I think the ReWriteBase / causes a problem with this rule
used by my content management system:
Code:
# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/_devel)($|/)
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?
\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA]
|
|
|
Code:
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.59
# Registration info
RegistrationName= XX
RegistrationCode= XXX
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.59
<VirtualHost www.mysite.com>
RewriteEngine On
# Send away some bots
RewriteCond %{HTTP:User-Agent}
(?:YodaoBot|Yeti|ZmEu|Morfeus\f**king\Scanner) [NC]
RewriteRule .? - [F]
# Ignore dirctories from FarCry Friendly URL processing
RewriteCond %{REQUEST_URI} !(^/_devel)($|/)
RewriteRule ^([a-zA-Z0-9\/\-\%:\[\]\{\}\|\;\<\>\?
\,\*\!\@\#\$\ \(\)\^_`~]*)$ /index.cfm?furl=$1 [L,PT,QSA]
# redirect all request of pubs folder to 404 page with
query string
RewriteBase /
RewriteRule ^pubs/(.+)\.pdf$ /404/?pub=$1.pdf
[NC,R=301,L]
#enabling rewrite.log
RewriteLogLevel 9
#enabling error.log
LogLevel debug
</VirtualHost>
|
|
|
|
| Back to Top |
|
| |
Guests Guest

Joined: 01 October 2003
Online Status: Online Posts: -149
|
| Posted: 01 February 2012 at 5:33am | IP Logged
|
|
|
Issues with rewrite.log are caused by permissions, Please, see the following article.
What does error.log say?
We need to see the request processing to identify problem.
regards
Andrew
|
| Back to Top |
|
| |
mightyaswell Newbie

Joined: 26 January 2012 Location: United States
Online Status: Offline Posts: 5
|
| Posted: 03 February 2012 at 11:28am | IP Logged
|
|
|
I solved this problem by adding ^/$ to the ReWriteCond that
my CMS uses to friendly urls. such has below.
RewriteCond %{REQUEST_URI} !(^/$|^/pubs|^/_devel|^/farcry)
($|/)
Thanks!
|
| Back to Top |
|
| |