You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Darly Coupet <ap...@tsgi.net> on 2006/11/16 16:10:51 UTC

[users@httpd] Rewriterule syntax not working

Hi,

Unable to get Rewriterule working

I have modified htaccess file in folder Merchant2 as follows:

RewriteEngine On
#RewriteRule ^old/URL/path$ http://yourdomain.com/new/path [R=301,L]

Redirect 301
/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
http://www.sitename.com/index.php?action=view_user&user=2


Thanks, Darly

Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
Hi Josha,

Thanks for excellent advise; the following works:

RewriteCond %{REQUEST_URI} ^/Merchant2/merchant.mv [NC]
RewriteCond %{QUERY_STRING}
^Screen\=CTGY\&Store_Code=AWLAS\&Category_Code\=Abc+Xyz$
RewriteRule (.*)
http://www.sitename.com/index.php?action=view_user&user=2[R=301,L]

On 11/17/06, Darly Coupet <ap...@tsgi.net> wrote:
>
> Hi Josha,
>
> Thanks for your patience and help.  I do not have access to a server and
> the application that is serving the old url's.
>
> I think it is a syntax issue, one old URL routed to one new URL.
>
> > Old url
> > http://www.sitename.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
>
> >
> > New URL
> > http://www.sitename.com/index.php?action=view_user&user=2
>
> #Begin htaccess content
> # htaccess is located is subfolder name Merchant2
> # merchant.mv is located is subfolder name Merchant2
>
> <IfModule mod_php4.c>
> php_value session.use_trans_sid 0
> </IfModule>
>
> RewriteEngine On
> RewriteBase /
>
> RewriteCond %{QUERY_STRING}
> ^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> RewriteRule merchant.mv
> http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]
>
> #End htaccess content
>
> Darly
>
> On 11/17/06, Joshua Slive <jo...@slive.ca> wrote:
> >
> > On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> > > I have also tried with quotes, same error message
> > > RewriteLog "/usr/local/var/apache/logs/rewrite.log"
> > >
> > >
> > > > your security could be compromised if the directory where logfiles
> > are
> > > stored is writable by anyone other than the user that starts the
> > server.
> > >
> > > I am on a virtual host, Hosting provider is probably
> > not  allowing  changes
> > > to RewriteLog
> > >
> >
> > Then install apache on your local server with as similar a config as
> > possible, test and debug it there using the RewriteLog, then upload
> > it.
> >
> > Sorry, but debugging mod_rewrite without the RewriteLog is like
> > driving blindfolded.
> >
> > Joshua.
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server
> > Project.
> > See <URL: http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
Hi Josha,

Thanks for your patience and help.  I do not have access to a server and the
application that is serving the old url's.

I think it is a syntax issue, one old URL routed to one new URL.

> Old url
>
http://www.sitename.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
>
> New URL
> http://www.sitename.com/index.php?action=view_user&user=2

#Begin htaccess content
# htaccess is located is subfolder name Merchant2
# merchant.mv is located is subfolder name Merchant2

<IfModule mod_php4.c>
php_value session.use_trans_sid 0
</IfModule>

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING}
^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
RewriteRule merchant.mv
http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]

#End htaccess content

Darly

On 11/17/06, Joshua Slive <jo...@slive.ca> wrote:
>
> On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> > I have also tried with quotes, same error message
> > RewriteLog "/usr/local/var/apache/logs/rewrite.log"
> >
> >
> > > your security could be compromised if the directory where logfiles are
> > stored is writable by anyone other than the user that starts the server.
> >
> > I am on a virtual host, Hosting provider is probably
> not  allowing  changes
> > to RewriteLog
> >
>
> Then install apache on your local server with as similar a config as
> possible, test and debug it there using the RewriteLog, then upload
> it.
>
> Sorry, but debugging mod_rewrite without the RewriteLog is like
> driving blindfolded.
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Joshua Slive <jo...@slive.ca>.
On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> I have also tried with quotes, same error message
> RewriteLog "/usr/local/var/apache/logs/rewrite.log"
>
>
> > your security could be compromised if the directory where logfiles are
> stored is writable by anyone other than the user that starts the server.
>
> I am on a virtual host, Hosting provider is probably not  allowing  changes
> to RewriteLog
>

Then install apache on your local server with as similar a config as
possible, test and debug it there using the RewriteLog, then upload
it.

Sorry, but debugging mod_rewrite without the RewriteLog is like
driving blindfolded.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
I have also tried with quotes, same error message
RewriteLog "/usr/local/var/apache/logs/rewrite.log"

your security could be compromised if the directory where logfiles are
> stored is writable by anyone other than the user that starts the server.


I am on a virtual host, Hosting provider is probably not  allowing  changes
to RewriteLog

Darly


On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
>
> I udated the Rewrite rule as follows:
> RewriteRule merchant.mv  http://www.sitename.com/index.php?action=view_user&user=2
> [R=301,L]
>
> It is not being rerouted.
>
> #This RewriteLog line gives an error message
> RewriteLog /home/site/www/Merchant2/logs_server_rewrite.txt
>
> 500 Internal Server error
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> I created the logs_server_rewrite.txt file (touch) and chmod 777
>
> Greatly appreciate your help.
>
> Darly
>
> On 11/16/06, Joshua Slive <jo...@slive.ca> wrote:
> >
> > On 11/16/06, Darly Coupet < apache@tsgi.net> wrote:
> > > Old url
> > > http://www.sitename.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
> >
> > >
> > > New URL
> > > http://www.sitename.com/index.php?action=view_user&user=2
> > >
> > > htaccess is located in folder Merchant2
> > >
> > > RewriteEngine On
> > > RewriteBase /
> > > RewriteCond %{QUERY_STRING}
> > > ^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> > > RewriteRule ^/Merchant2/merchant.mv
> > > http://www.sitename.com/index.php?action=view_user&user=2
> > > [R=301,L]
> > >
> > > It s still not being rerouted.
> >
> > Third try: Use the RewriteLog!
> >
> > Given that you are in an .htaccess file, the RewriteRule will be
> > matching relative to the current URL-path, so you probably want
> > RewriteRule merchant.mv ...
> >
> > You're welcome to post again, but I'm not personally going to help you
> > anymore unless you try to help yourself a little
> >
> > Joshua.
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP Server
> > Project.
> > See <URL: http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
> >
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
I udated the Rewrite rule as follows:
RewriteRule merchant.mv
http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]

It is not being rerouted.

#This RewriteLog line gives an error message
RewriteLog /home/site/www/Merchant2/logs_server_rewrite.txt

500 Internal Server error
The server encountered an internal error or misconfiguration and was unable
to complete your request.

I created the logs_server_rewrite.txt file (touch) and chmod 777

Greatly appreciate your help.

Darly

On 11/16/06, Joshua Slive <jo...@slive.ca> wrote:
>
> On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> > Old url
> >
> http://www.sitename.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
> >
> > New URL
> > http://www.sitename.com/index.php?action=view_user&user=2
> >
> > htaccess is located in folder Merchant2
> >
> > RewriteEngine On
> > RewriteBase /
> > RewriteCond %{QUERY_STRING}
> > ^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> > RewriteRule ^/Merchant2/merchant.mv
> > http://www.sitename.com/index.php?action=view_user&user=2
> > [R=301,L]
> >
> > It s still not being rerouted.
>
> Third try: Use the RewriteLog!
>
> Given that you are in an .htaccess file, the RewriteRule will be
> matching relative to the current URL-path, so you probably want
> RewriteRule merchant.mv ...
>
> You're welcome to post again, but I'm not personally going to help you
> anymore unless you try to help yourself a little
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Joshua Slive <jo...@slive.ca>.
On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> Old url
> http://www.sitename.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
>
> New URL
> http://www.sitename.com/index.php?action=view_user&user=2
>
> htaccess is located in folder Merchant2
>
> RewriteEngine On
> RewriteBase /
> RewriteCond %{QUERY_STRING}
> ^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> RewriteRule ^/Merchant2/merchant.mv
> http://www.sitename.com/index.php?action=view_user&user=2
> [R=301,L]
>
> It s still not being rerouted.

Third try: Use the RewriteLog!

Given that you are in an .htaccess file, the RewriteRule will be
matching relative to the current URL-path, so you probably want
RewriteRule merchant.mv ...

You're welcome to post again, but I'm not personally going to help you
anymore unless you try to help yourself a little

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
Old url
http://www.sitename.com/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz

New URL
http://www.sitename.com/index.php?action=view_user&user=2

htaccess is located in folder Merchant2

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING}
^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
RewriteRule ^/Merchant2/merchant.mv
http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]

It s still not being rerouted.

Thanks, Darly

On 11/16/06, Joshua Slive <jo...@slive.ca> wrote:
>
> On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> > RewriteCond %{QUERY_STRING}
> >
> /Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
> > RewriteRule ^/$
> > http://www.sitename.com/index.php?action=view_user&user=2
> > [R=301,L]
> >
> > The condition is not met; It is going to the old url.
> > It should redirect to the new url when the old string (url) is true.
>
> If you were using the RewriteLog, you'd see that the contents of the
> %{QUERY_STRING} is the part after the question mark.
>
> RewriteCond %{QUERY_STRING}
> ^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> RewriteRule ^/Merchange2/merchant.mv
> http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Joshua Slive <jo...@slive.ca>.
On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> RewriteCond %{QUERY_STRING}
> /Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
> RewriteRule ^/$
> http://www.sitename.com/index.php?action=view_user&user=2
> [R=301,L]
>
> The condition is not met; It is going to the old url.
> It should redirect to the new url when the old string (url) is true.

If you were using the RewriteLog, you'd see that the contents of the
%{QUERY_STRING} is the part after the question mark.

RewriteCond %{QUERY_STRING} ^Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
RewriteRule ^/Merchange2/merchant.mv
http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
RewriteCond %{QUERY_STRING}
/Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
RewriteRule ^/$
http://www.sitename.com/index.php?action=view_user&user=2[R=301,L]

The condition is not met; It is going to the old url.
It should redirect to the new url when the old string (url) is true.

Thanks, Darly

On 11/16/06, Joshua Slive <jo...@slive.ca> wrote:
>
> On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> > RewriteRule
> > ^/merchant.mv\?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> > http://www.sitename.com/index.php?action=view_user&user=2
> > [R=301,L]
> >
> > I have tried the above, but not working.
>
> Telling us that it is "not working" is not a good way to get help.
> Tell us exactly what happened.
>
> With mod_rewrite, you need to use the RewriteLog to debug.
>
> But your first problem is that you need to read the docs for
> RewriteRule, and in particular the box that is titled "Query String".
> It tells you that RewriteRule doesn't match against the query string.
> You need to use RewriteCond %{Query_String}
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Joshua Slive <jo...@slive.ca>.
On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> RewriteRule
> ^/merchant.mv\?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
> http://www.sitename.com/index.php?action=view_user&user=2
> [R=301,L]
>
> I have tried the above, but not working.

Telling us that it is "not working" is not a good way to get help.
Tell us exactly what happened.

With mod_rewrite, you need to use the RewriteLog to debug.

But your first problem is that you need to read the docs for
RewriteRule, and in particular the box that is titled "Query String".
It tells you that RewriteRule doesn't match against the query string.
You need to use RewriteCond %{Query_String}

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Rewriterule syntax not working

Posted by Darly Coupet <ap...@tsgi.net>.
RewriteRule
^/merchant.mv\?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz$
http://www.sitename.com/index.php?action=view_user&user=2 [R=301,L]

I have tried the above, but not working.

Thanks, Darly

On 11/16/06, Joshua Slive <jo...@slive.ca> wrote:
>
> On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> > Hi,
> >
> > Unable to get Rewriterule working
> >
> > I have modified htaccess file in folder Merchant2 as follows:
> >
> > RewriteEngine On
> > #RewriteRule ^old/URL/path$ http://yourdomain.com/new/path [R=301,L]
> >
> > Redirect 301
> >
> /Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
> > http://www.sitename.com/index.php?action=view_user&user=2
>
> And what happened?
>
> Luckily, in this case I can guess.
>
> For URL manipulation involving a query string, you must use
> mod_rewrite.  mod_alias and the Redirect directive will not work.
>
> Joshua.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Rewriterule syntax not working

Posted by Joshua Slive <jo...@slive.ca>.
On 11/16/06, Darly Coupet <ap...@tsgi.net> wrote:
> Hi,
>
> Unable to get Rewriterule working
>
> I have modified htaccess file in folder Merchant2 as follows:
>
> RewriteEngine On
> #RewriteRule ^old/URL/path$ http://yourdomain.com/new/path [R=301,L]
>
> Redirect 301
> /Merchant2/merchant.mv?Screen=CTGY&Store_Code=AWLAS&Category_Code=Abc+Xyz
> http://www.sitename.com/index.php?action=view_user&user=2

And what happened?

Luckily, in this case I can guess.

For URL manipulation involving a query string, you must use
mod_rewrite.  mod_alias and the Redirect directive will not work.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org