Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-20-2012, 12:40 PM   PM User | #1
jtdeveloper
New to the CF scene

 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
jtdeveloper is an unknown quantity at this point
htaccess help

Hi all. Can anybody possibly help me with my htaccess file. It's got a problem in there somewhere which is stopping everything from working but for the life of me I can't see where. I'm only doing 2 things: ensuring www is used as the main url, and making search engine-friendly urls. Also if anybody knows how to change the "offers" bit so that I don't have to enter every offer page (rather, it processess any "pos=XX" dynamically) that would be awesome.

thanks all...

Options -Multiviews
RewriteEngine On
RewriteBase /

# Force search engines to use www.someurl.co.uk
RewriteCond %{HTTP_HOST} !^www\.someurl\.co\.uk$
RewriteRule ^(.*) http://www.someurl.co.uk/$1 [R=301,L]

# Specify search friendly URLs
RewriteRule ^top-ten$ /index.php [L]
RewriteRule ^what-is-it$ /what-is-it.php [L]
RewriteRule ^contact-us$ /contact-us.php [L]
RewriteRule ^offer-1$ /offer.php?pos=1 [L]
RewriteRule ^offer-2$ /offer.php?pos=2 [L]
RewriteRule ^offer-3$ /offer.php?pos=3 [L]
RewriteRule ^offer-4$ /offer.php?pos=4 [L]
RewriteRule ^offer-5$ /offer.php?pos=5 [L]
RewriteRule ^offer-6$ /offer.php?pos=6 [L]
RewriteRule ^offer-7$ /offer.php?pos=7 [L]
RewriteRule ^offer-8$ /offer.php?pos=8 [L]
RewriteRule ^offer-9$ /offer.php?pos=9 [L]
RewriteRule ^offer-10$ /offer.php?pos=10 [L]
jtdeveloper is offline   Reply With Quote
Old 11-27-2012, 04:56 PM   PM User | #2
Rowsdower!
Senior Coder

 
Rowsdower!'s Avatar
 
Join Date: Oct 2008
Location: Some say it's everything.
Posts: 2,007
Thanks: 5
Thanked 395 Times in 388 Posts
Rowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura aboutRowsdower! has a spectacular aura about
This is what I use to force a "www" prefix:

Code:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I'm not sure if your version is the cause of your problem or not, but I at least like the portability of my version.

For the second part, I think your syntax is backwards (your match and replacement are reversed). And to get the numbered items into a single line you use a regular expression match instead of the literal string you are trying to match. Try this (untested):

Code:
#note: I'm not sure if the question mark needs to be escaped or not, but I went ahead and escaped it...
RewriteRule ^(offer.php\?pos=[0-9]) offer-1$ [L]
__________________
The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
See Mediocrity in its Infancy
It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
Seek and you shall find... basically:
validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting
Rowsdower! is offline   Reply With Quote
Reply

Bookmarks

Tags
error, friendly, htaccess, rewrite, search

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:49 AM.


Advertisement
Log in to turn off these ads.