regex - 500 internal error on regular linux hosting for php


here is my code in .htaccess

<Directory "/">
AllowOverride All
RewriteEngine on
RewriteRule ^custom  contactus.php[NC L]

Remote site path or my all website files contains in /www

current url

expected output




Try the following rule.

RewriteEngine On
RewriteRule ^custom$ /contactus.php [L]



Invalid htaccess file

A Directory directive is invalid in a.htaccess file:

Description: Enclose a group of directives that apply only to the named file-system directory, sub-directories, and their contents

Context: server config, virtual host

Note that.htaccess is not a valid context. Similarly, AllowOverride is also invalid in a.htaccess file:

Description: Types of directives that are allowed in .htaccess files

Context: directory

Were it valid in a.htaccess file, it would defeat the purpose of what the directive is for.

Valid example

The entire contents of the.htaccess file to do what's in the question are:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^custom  contactus.php [NC,L]

I.e. If mod rewrite is enabled, apply that rewrite rule. Note that the syntax for rewrite flags is a comma separated list.

People are also looking for solutions to the problem: javascript - Disable 2 buttons after click of a button


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.