1
votes

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

1
Can you post what you have tried to rewrite the url? - Amit Verma
I have updated the code. Please check. I have no clue how to achieve it. Tried all solutions at Stackoverflow. - Arijit Aich
LoadModule rewrite_module modules/mod_rewrite.so - Deadooshka

1 Answers

1
votes

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]