How come the next htaccess file generate 300 errors, if this URL is known as?


URL: hxxp://subdomain.domainame.com/keyworda/

IndexIgnore *

RewriteEngine on
RewriteRule ^([a-z]+)/$ /index.php?p=$1


Error log: 300 hxxp://subdomain.domainame.com/keyworda (no trailing slash)

Edit, I had been attempting to keep my answer short, I did not mean that you should add this line exactly. It had been simply to show in which the missing slash is going.

RewriteRule ^/([a-z]+)/$ /index.php?p=

I am presuming you're editing b .conf file, inside your apache config directory. Chigley's response is presuming you're editing a per-directory .htaccess config file.

Edit your conf file to appear such as this:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_METHOD} ^TRACE
  RewriteRule .* - [F]
  RewriteRule ^/(test[a-z]+)/$ /index.php?id=$1 [L,R=301]
  ... your current stuff afterwords ...
</IfModule>
  • I believe the issue is you'll need the first '/' in yoru RewriteRule.
  • Putting my test RewriteRule first will make certain it's the one matching.
  • I put in the "test" prefix, which means this line wont hinder the relaxation of the website. This makes it simpler to isolate this rule. So, when testing, the url must finish having a "/" and start with "test" for this to complement, additionally to getting 1 or even more a-z.
  • The hyperlink to test is: hxxp://...yourserver.../testkeyword/
  • This will alter the url inside your browser to: hxxp://...yourserver.../index.php?id=testkeyword
  • The 404 error you're seeing often means: 1) No rules match, and there's no file that suits your keyword. 2) A number of rules match, however the resulting url doesn't suit your php files.

Once it's working, this is actually the real RewriteRule to make use of inside your conf file:

RewriteRule ^/([a-z]+)/$ /index.php?id=$1 [L,R=301]

If it doesn't work, edit your question to incorporate the entire code within the block, as well as your httpd version, such as this:

# httpd -v
Server version: Apache/1.3.33 (Darwin)
Server built:   Mar 20 2005 15:08:27

Most likely does not matter, but simply incase...

This is actually the mod_write documentation. You will find some good examples in the very bottom.

are you able to try that one:

RewriteRule ^([^/]+)/?$ /index.php?p=$1

Try

RewriteRule ^([a-z]+)/?$ /index.php?p=$1 [L]