Ticket #2381 (new enhancement)

Opened 9 months ago

Last modified 3 months ago

HTACCESS improvement

Reported by: T3hDuk Owned by: aoneil
Priority: medium Milestone:
Component: (Unknown) Version: 2.2.2-rc2
Severity: medium effort / impact Keywords:
Cc: Hours:

Description

This will redirect http://mysite.com/contact_us --> http://mysite.com/contact_us/ (For SEO puposes) However it requires the user to rewrite the "mysite" in the space below. Maybe someone with another mod_rewrite trick can improve a bit more. (That or give me a bit and I may figure it out)


### SILVERSTRIPE START ### RewriteEngine? On

RewriteCond? %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ RewriteCond? %{REQUEST_URI} !/$ # Redirect to add a trailing slash RewriteRule? (.*) http://a1scubagear.com/SilverStripe/$1/ [R=301,L]

RewriteCond? %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ RewriteCond? %{REQUEST_URI} (.*)$ RewriteCond? %{REQUEST_FILENAME} !-f RewriteRule? .* sapphire/main.php?url=%1&%{QUERY_STRING} [L] ### SILVERSTRIPE END ###

Change History

Changed 9 months ago by ischommer

thanks, good poin!

to clarify - he's adding a trailing slash to the URL.

is there a way to avoid hardcoding the absolute URL (http://a1scubagear.com/SilverStripe/$1/) in the rule? we can't require users to change this manually, or rely on the installer script rewriting it dynamically.

Note: See TracTickets for help on using tickets.