Forum Moderators: phranque
we have used more time rewrite with link as
http://www.example.com/12.html or
http://www.example.com/12/page_title.html
instead
http://www.example.com/read.php?id=12
Now
we must make this but without id on link
For make this we have 2 way:
1. apache redirect all page to redir.php where we search page title on dbase and obtain id. After put content with id.
Example:
first.html
search on dbase for title first and obtain id
redirect to page.php?id=x
2. there is a redirect list, created with cms backend where there are name -> id.
Example:
first.html -> page.php?id=12
second.html -> page.php?id=17
third.html -> page.php?id=4
What do you think best solution?
What too slow and why?
What more difficult to realized?
Thks
:)
This works well with a RewriteMap calling a PERL script which accesses a MySQL database, for example.
This method requires modifications to httpd.conf or conf.d server configuration files, and so cannot be used on most shared hosting accounts.
Jim
There is all 2 solution about posted question, but.. we have not understand if must modify apache httpd.conf
we have try this but don't run :(
_____________________________________________
We'll start by creating the map file. We'll call it fish.map and put it in /usr/local/apache/conf, and it will look like this:
carp [fish.net...]
trout [fishermen.com...]
guppy [guppies.org...]
whale [moby.dick.net...]
In the next step, we create a map name for that file, so that we can use it in RewriteRules.
RewriteMap fishmap txt:/usr/local/apache/conf/fish.map
And, finally, we'll use it in an actual RewriteRule. In this case, we want to redirect some requests for various fishes to sites about those fishes.
RewriteEngine OnRewriteRule ^/fish/(.*) ${fishmap:$1} [R]
Now, when someone visits [myserver...] they will be redirected to [guppies.org...] instead.
________________________________________
perl is the only solution for dynamic? php cannot use on this?
Thks & sorry for bad english ;)
we think to use this
RewriteRule ^(.+).html$ constructor.php?name=$1 [L]
constructor.php search name of page in database that have page name as key
but..
we have try this for use php page but don't work
RewriteRule ^([^/]+).php$ constructor.php?name=$1 [l]
we must also add 2 rules:
1. skip any page
2. complete link with all GET var
1. we must indicate 4/5 page to not parse because static
2. if is call page myname.php?var1=value&var2=value we must call page constructor.php?name=myname&var1=value&var2=value
how to this?
thks :)
RewriteRule ^([^/]+).php$ constructor.php?name=$1 [l]
You must qualify it so this does not happen:
RewriteCond %{REQUEST_URI} !^/constructor\.php$
RewriteRule ^([^.]+)\.php$ constructor.php?name=$1 [QSA,L]
> we must also add 2 rules:
> 1. skip any page
Not clear. Do you mean "skip any page which actually exists as a static page"? If so, add
RewriteCond {%REQUEST_FILENAME} !-f
> 2. complete link with all GET var
Fixed with [QSA] in first example above.
> 1. we must indicate 4/5 page to not parse because static
Use
RewriteCond %{REQUEST_URI} !^/excluded_page_path
as in the first example above.
> 2. if is call page myname.php?var1=value&var2=value we must call page constructor.php?name=myname&var1=value&var2=value
Fixed using [QSA] in first example. above.
Jim
really usefull ;)
we try immediately
we like to use .php and not .html for the called page.. but users can like .html, what do you think about this?
User could prefer call (and remember) index.html or index.php?
and if you think .html is better is possible to use it but as php: index.html?var1=3&var2=4
thks for help
This can be final solution :D
the only problem is that 'all' page called is send to parser also page that exist :(
test on local with winxp/apache
all other site that is on local work great with rewrite mod
?
thks