I am creating a rule to interpret addresses that after domain begin with #
followed by numbers or followed by letters whose rule should only be read if there is no file or directory that matches the path indicated:
# Rewrite the url
<IfModule mod_rewrite.c>
RewriteEngine On
#DirectorySlash Off
RewriteBase /
# se não for ficheiro
RewriteCond %{REQUEST_FILENAME} !-f
# se não for directoria
RewriteCond %{REQUEST_FILENAME} !-d
# regra se começar por # seguido de letras com -
RewriteRule ^#([a-zA-Z])/ index.php?mod=books&slug=$1 [L,PT]
# regra se começar por # seguindo de números
RewriteRule ^#([0-9]+)/ index.php?mod=books&id=$1 [L,PT]
</IfModule>
The idea I am trying to implement is to direct the visitor to the index.php
file in the root of the domain if it is trying to access specific content that can be identified by its ID or a Slug of its name :
Objective
Below are two examples of what I'm trying to achieve:
-
If you get a Slug:
http://www.example.com/#as-causas-e-os-acasos
route to:
http://www.example.com/index.php?mod=books&slug=#as-causas-e-os-acasos
-
If you receive an ID:
http://www.example.com/#23
route to:
http://www.example.com/index.php?mod=books&id=#23
Problem
As it stands right now, nothing comes to PHP, that is, I do not have the variable mod
nor the variable id
or slug
as the case may be.