Apache rewrites the slash rule

The leading slash argument is: ignored?

What is the difference between the syntax

RewriteRule help help.php?q=noslash [L]     #1
RewriteRule /help help.php?q=withslash [L]  #2

If I hit http: // localhost / help , he goes to # 1, if I click http: // localhost // help he still refers to # 1.

Am I rightly saying that the leading slash in the first argument of the RewriteRule is essentially ignored?

Slash leading second argument: error?

Also, why does this rewrite rule not work?

RewriteRule help /help.php [L]     #1

Putting a leading slash before the second arg actually creates a 500 error for the server. Why?

I should note that I use the .htaccess file to write these rules to

+6
source share
5

,

RewriteRule   ^/help    help.php?q=2              [L]

.

:

RewriteRule   ^help      help.php?q=1             [L]

http://localhost/help, http://localhost//help http://localhost///help

, RewriteRule , , TheCoolah, ( 0.. .htaccess ), , .

,

RewriteRule   ^help    /help.php

Apache Mod_rewrite

... , http:// , . , , , .

/help.php help.php, .

/help.php URL ( ), [PT]:

RewriteRule   ^/help    /help.php    [PT]

http://localhost/help http://localhost/help.php.

+12

: - . Apache, Tomcat Jetty. Unix . , - :

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ 
+4

help "" .

/help , rewriterule (.. ^, / ^/) ).

( , %{REQUEST_URI} rewritecond, %{REQUEST_URI} . %{REQUEST_URI}, ^ ^/ , .)

. "help" "/help.php" , , . , "/help.php" "/help.php" , URL-, .

, end (.. [end]), Apache 2.3.9+, Apache 2.2, -, . , ; ^help$ .

+1

RewriteRule , URL ( , ), . , .

I am not sure what can cause 500 errors in the second part; double-slashes may not collapse after starting the rewrite mechanism and then generate a server error.

0
source

The cause of error 500 is an infinite loop:

  • help is written in / help
  • / help is removed to help
  • help corresponded / help, etc. until the limit of MaxRewrites → 500 is reached

If a rule overwrites help, Apache is smart enough to abort rewriting at that point.

-1
source

All Articles