Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

.htaccess mod_rewrite - send all 404 to PHP script aling with full query string

Posted on 2008-11-12
3
Medium Priority
?
645 Views
Last Modified: 2012-05-05
I need a rewrite rule to take all unknown directory/file requests that have no match and point them to a specific url, along with the full query string of the original request

so I need this:
http://example.com/computing/audio/speakers/logitech
to point to:
/index.php?action=oldLinkConversion&queryString=/computing/audio/speakers/

And I need this:
http://example.com/computing/audio/speakers/logitech/9700730403.html
to point to:
/index.php?action=oldLinkConversion&queryString=/computing/audio/speakers/logitech/9700730403.html

I know this is wrong, but I think I am going in the right direction:
Options +FollowSymlinks
RewriteEngine      On
RewriteCond            %{REQUEST_FILENAME} !-f
RewriteCond            %{REQUEST_FILENAME} !-d
RewriteRule            ^(*)$ /index.php?action=oldLinkConversion&queryString=$1

Ideas?
0
Comment
Question by:trickyidiot
  • 2
3 Comments
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 22945264
Yes, very close. A period '.' (=1 or n characters) was/is missing in your rule-pattern:
Options +FollowSymlinks
RewriteEngine      On
RewriteCond            %{REQUEST_FILENAME} !-f
RewriteCond            %{REQUEST_FILENAME} !-d
RewriteRule            ^(.*)$ /index.php?action=oldLinkConversion&queryString=$1 [QSA,L]

Open in new window

0
 
LVL 27

Expert Comment

by:caterham_www
ID: 22945281
to be more correct:
.  stands for [one] any character
and .* makes it to 1 or n of "any characters"
0
 
LVL 6

Author Closing Comment

by:trickyidiot
ID: 31516202
Perfect - Thank you!
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Six Sigma Control Plans
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question