Mobile app version of vmapp.org
Login or Join
XinRu657

: .htaccess issue (500 - Internal Server Error) error I was trying to learn how to edit and make a .htaccess file using a tutorial found at corz.org, I copied an existing .htaccess file from

@XinRu657

Posted in: #Htaccess #HttpCode500 #Redirects #Wamp #Windows

I was trying to learn how to edit and make a .htaccess file using a tutorial found at corz.org, I copied an existing .htaccess file from another site on my localhost and pasted the following content in it:

RewriteEngine on
RewriteRule ^(.*).html$ $a.php [NC]


I was trying to learn how to redirect HTML pages to some PHP page.

My questions are:


I tried doing Right Click > New > Text Document > Renaming it ".htaccess". It should work but it gave an error that I must provide file name. But when I pasted .htaccess file here it was pasted successfully... Why is this? the same rules should apply to .htaccess file and it should generate some error.
I have pasted the exact code and checked for any space UN-intentionally left, but still internal server error 500 occurs. Why is this?


Note: I am using Microsoft Windows and Wamp version 2.2

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @XinRu657

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

I use this:

Options +FollowSymLinks
RewriteEngine On #RewriteBase /

# check if the file don't exists then redirect
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ .php [NC,L]


and it works fine, the $a should be .


RewriteEngine On Enables the rewrite engine IF mod_rewrite is enabled.
RewriteBase / Executes all the rules from the root (/) directory.



RewriteRule ^(.*).html$ .php [NC,L]




^ means Starts with.
(.*) means everything. Although, I prefer using ([a-z0-9_-]+) which only allows letters, numbers, underscores and dashes
means the first matching regular expression that the rule found.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme