jroakes
jroakes

Reputation: 369

Rewrite Querystring to File

I mirrored our Basecamp install to a Google Cloud Disk using wget. Many of the pages that were created are using the following file names:

Files

files.html?page=4
files.html?page=5
files.html?page=6
files.html?page=7
files.html?page=8
files.html?page=9

index

log?n=0

We were able to fix the index issue with log%3fn=0:

DirectoryIndex index.html index.htm log%3fn=0 log report new_more new

I wanted to see if there were a way to add a rewrite in .htaccess that will make

000.000.000.000/projects/11424851-m-domain-com/files.html?page=2

resolve to the file name that contains a query-string in it.

I am thinking the rewrite would have to produce:

000.000.000.000/projects/11424851-m-domain-com/files.html%3fnpage=2

Thank for any help!!

Upvotes: 0

Views: 44

Answers (1)

outlyer
outlyer

Reputation: 3943

You can use something like:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^page=(.*)$
RewriteRule ^(.*)$ %{REQUEST_URI}\%3Fnpage=%1? [L]

I.e. match query strings starting with page=, and redirect to the same filename with the query string appended in escaped form.

Upvotes: 1

Related Questions