Adding custom htaccess redirect rules question

Hi

I have the following .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? /page.php [L]

RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule .? http://www.domain.com%{REQUEST_URI} [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /.*index\\.php\\ HTTP/
RewriteRule ^(.*)index\\.php$ /$1 [L,R=301]

and I would like to add this line, but can’t get it work anywhere in the file. Any ideas?


RewriteRule account/(.*) step2.php?package=$1 [NC,L]

Given what you’ve shown, it should work as the first rewrite rule.

RewriteEngine on

[COLOR="#FF0000"]RewriteRule account/(.*) step2.php?package=$1 [NC,L][/COLOR]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? /page.php [L]

RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule .? http://www.domain.com%{REQUEST_URI} [L,R=301]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\\ /.*index\\.php\\ HTTP/
RewriteRule ^(.*)index\\.php$ /$1 [L,R=301]

I copy-pasted your code to double check, and this works for me.

Hi Jeff,

I tried adding it at the top as shown in the last post but it still doesn’t redirect for me…

Z,

Try:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule .? http://www.domain.com%{REQUEST_URI} [L,R=301]

RewriteRule account/(.*) step2.php?package=$1 [L] # Do not use NC in a RewriteRule

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? page.php [L] # No need to specify DocumentRoot when you're in the DocumentRoot

RewriteCond %{THE_REQUEST} .+/index\\.php # Overly complex for no reason; require at least one char before index.php
RewriteRule ^(.*)index\\.php$ /$1 [L,R=301] # Why not display the DirectoryIndex? The reason for this baffles me.

Regards,

DK

Hi DK,

Thanks - but the issue still persists. The link I want to redirect is:

http://www.domain.com/account/Bronze

should go to:

http://www.domain.com/step2.php?package=Bronze

I tried the code you posted but still doesn’t work :frowning: strange.

There must be something more going on than what you’ve shown us. Other htaccess or other configuration.

Z,

That’s strange, indeed! There is nothing to redirect FROM step2.php IF (and only if) step2.php exists.

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule .? http://www.domain.com%{REQUEST_URI} [L,R=301]
# Does not change {REQUEST_URI}

RewriteRule account/(.*) step2.php?package=$1 [L] # Do not use NC in a RewriteRule
# Will match account/Bronze and redirect to step2.php?package=Bronze

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? page.php [L] # No need to specify DocumentRoot when you're in the DocumentRoot
# Will not redirect step2.php to page.php IF (and only if) step2.php does not exist (as a file or as a directory)

RewriteCond %{THE_REQUEST} .+/index\\.php # Overly complex for no reason; require at least one char before index.php
RewriteRule ^(.*)index\\.php$ /$1 [L,R=301] # Why not display the DirectoryIndex? The reason for this baffles me.
# Ditto if {THE_REQUEST} and {REQUEST_URI} contains index.php, it will redirect but NOT if it's step2.php. 

Regards,

DK

Hi,

Sorry for the delayed reply.

I tried the latest code but now it’s giving a 500 internal server error. Not sure whats wrong now…