1

Current URL: http://broom.xyz/index.php?tag=C/santa

GOAL URL: http://broom.xyz/C/santa

Note: The Tag 'C/santa' is a single dynamic value.
It can change to anything like 'F/fanta' or 'M/Manta'.

My Code:

RewriteEngine On
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^([^/]*)$ /index.php?tag=$1 [L]

This Code Generates A 500 Internal Server Error. Here Is The Error Log:

[Fri Apr 07 13:33:10.469218 2017] [core:alert] [pid 4202] [client 47.11.122.64:52755] /var/www/html/workspace/broom/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration [Fri Apr 07 13:40:31.595944 2017] [core:alert] [pid 4185] [client 47.11.122.64:53076] /var/www/html/workspace/broom/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

3
  • Can you post what you have tried to rewrite the url? Commented Apr 7, 2017 at 13:11
  • I have updated the code. Please check. I have no clue how to achieve it. Tried all solutions at Stackoverflow. Commented Apr 7, 2017 at 13:22
  • LoadModule rewrite_module modules/mod_rewrite.so Commented Apr 7, 2017 at 15:01

1 Answer 1

1

Your Rule's pattern does not match the uri C/Santa but matches CSanta This is because you have excluded the / in your pattern ^([^/]*) . You need to fix it so that it can accept any chars in the uri.

Replace your RewriteRule line with this :

RewriteRule ^(.+)$ /index.php?tag=$1 [L]
Sign up to request clarification or add additional context in comments.

4 Comments

No. It didn't work. Gives a 500 Internal Server Error.
Please check your error log for info about the 500internal server error.
[Fri Apr 07 13:33:10.469218 2017] [core:alert] [pid 4202] [client 47.11.122.64:52755] /var/www/html/workspace/broom/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration [Fri Apr 07 13:40:31.595944 2017] [core:alert] [pid 4185] [client 47.11.122.64:53076] /var/www/html/workspace/broom/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Your server is causing this error due to one of the following reasons : 1) You misspelled the The directive RewriteEngine try changing it to RewriteEngine on if that was a typo. 2)Mod-rewrite isnt enabled , Check if mod-rewrite is enabled on your server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.