0

I have a fairly standard mod_rewrite that comes packaged with a CMS called Modx and FURL's are working fine.

It will rewrite

It is configures as below.

# Friendly URLs Part
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .
# Force all pages to go to www.domain.co.uk for SEO
RewriteCond %{HTTP_HOST} !^www\.domain\.co.uk [NC]
RewriteRule (.*) http://www.domain.co.uk/dev/$1 [R=301,L]
# Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ dev/index.php?q=$1 [L,QSA]

Now I want to add an additional condition that will rewrite an additional query string:

Note *company_id* and *company_id* should be numbers in the actual rewrite.

Have tried a number of iterations but still can not get success.

Help appreciated!!

1 Answer 1

1
# Friendly URLs Part
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} .

# Force all pages to go to www.domain.co.uk for SEO
RewriteCond %{HTTP_HOST} !^www\.domain\.co.uk [NC]
RewriteRule (.*) http://www.domain.co.uk/dev/$1 [R=301,L]
#are your sure the above rule shouldn't be :
#RewriteRule (.*) http://www.domain.co.uk/$1 [R=301,L]

# Friendly URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ dev/index.php?q=$1 [L,QSA]

#company url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(company)/([^/]+)$ dev/index.php?q=$1&companyid=$2 [L,QSA]
Sign up to request clarification or add additional context in comments.

7 Comments

Gerben - thanks for the answer but unfortunately it doesn't / I can't get it to work still. I have copied your code but when I examine the server vars via php it returns "REDIRECT_QUERY_STRING = q=company/***id_here***" which to me implies that it is not translating the final "/***id_here***" to be &companyid=***id_here*** where id_here is the actual integer id obviously - Any suggestions much appreciated!
REDIRECT_QUERY_STRING contains the original url. $_GET['companyid'] should contain the id.
Gerben thanks for your help. Using $_GET['companyid'] didn't work. I moved the 'company URL' block above the 'Friendly URL' block and it does now work BUT the final url is like domain.com/dev/company/?company_id=1 I was hoping for no traditional query string so domain.com/dev/company/1 - I think it fires both rules which is why the last query string re-appears but I thought using [L] enforced that to be the last rule run - any ideas? Thanks
38 days later! Are you serious?
Been abroad with work - life has been on hold...but yes still very very serious! Thanks for your help so far anyhow.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.