4
I am creating a rule for interpreting addresses that after the domain begin with #
followed by numbers or followed by letters whose rule should only be read if there is no file or directory matching the given path:
# 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’m trying to implement aims to direct the visitor to the file index.php
at 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 receive a Slug:
http://www.example.com/#as-causas-e-os-acasos
directs 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
directs to:
http://www.example.com/index.php?mod=books&id=#23
Problem
The way it is now, nothing comes to PHP, IE, I do not have the variable mod
nor the variable id
or slug
as appropriate.
As far as I know, the browser does not send the hash in the request.
– bfavaretto
@bfavaretto I have been conducting tests to ascertain what you said and it really seems that I cannot handle it the way intended.
– Zuul
@bfavaretto This is a site with 3 year single-page type (hundreds of sub-pages with navigation via script / CSS animations). A URL manipulation is now being applied, specifically the hash. The idea is to copy the URL, save it in the bookmarks, use it on social networks, etc and get through this manipulated URL to reach a specific content on the page.
– Zuul