Quantcast
Channel: Tricky .htaccess settings
Viewing all articles
Browse latest Browse all 10

Tricky .htaccess settings

$
0
0

@raseone wrote:

Thank you habilis. Well said. Saves me a wild-goose-chase.

That was a great suggestion. I was sure it was going to work but… I’ve actually tried adding several variations of the “last flag”. It doesn’t hurt anything but it doesn’t solve the problem either

STRIP UNWANTED QUERY STRINGS FROM ALL BUT EXEMPTED FILES

RewriteCond %{query_string} .
RewriteCond %{THE_REQUEST} !^./item.php?(.)
RewriteCond %{THE_REQUEST} !^./free_item.php?(.)
RewriteRule (.*) /$1? [R=301,L]

PRETTY URLS FOR DYNAMIC PAGES V2

RewriteRule ^([a-zA-Z0-9]+)$ item.php?font=$1
RewriteRule ^([a-zA-Z0-9]+)/$ item.php?font=$1

I’ve tried several other variants of each of these 2 sets of conditions & rules but the 2 methods above cause the least trouble. Some attempts would break the whole site or produce broken pages. The combination of these 2 just causes unwanted stripping of the query strings from the target file (item.php)… a relatively gentle failure.

I may have to try a totally different tact.

I’m thinking if I were to strip the file extensions from all pages with something like the “pretty url” rules for all pages it might sufficiently dissuade the adding of unwanted queries since the real file name would not be known. Then I could ditch the “strip unwanted…” bit all together.

I should be able to do something like:

^/items/([a-zA-Z0-9]+)/$ item.php?itemname=$1
^/free_items/([a-zA-Z0-9]+)/$ free_item.php?itemname=$1
^/contact$ cont.php
^/privacy$ priv.php

There are only a handful of top-level, static links I would need to rewrite. Any thoughts on how I could do this better?

Read full topic


Viewing all articles
Browse latest Browse all 10

Trending Articles