Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite php? ...

         

editordude

11:29 pm on May 2, 2005 (gmt 0)

10+ Year Member



Hey people, I've read around for hours now and am only getting more lost. Here's my situation, I have links like so:

[mydomain.com...] Title

I want this to become:

[mydomain.com...]

* Notice spaces are converted to hyphens.
I'm needing either someone to post a solution or give someone which explains real basically for me.

Would greatly appreciate it.

editordude

1:45 am on May 3, 2005 (gmt 0)

10+ Year Member



In fact no .htaccess codes seem to be working, not even simple re-directs. What kind of test could I perform to test if all is well?

My host is apache and does allow mod rewrites and so on.

jdMorgan

3:30 am on May 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Test code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^foo\.html$ /bar.html [L]

"foo.html" should be a file that does not exist. "bar.html" should be a file that does exist, and that is easily recognizable to you.

Request "foo.html" from your server, and you should see the contents of "bar.html".

If it doesn't work, see your server error log -- it often gives very good information about the problem.

For more information on rewriting URLs, see jd01's recent excellent post [webmasterworld.com].

If you are on Apache 1xx, then there is a common error that often prevents rewriting of php URLs. In many cases, the Loadmodule order is incorrect, and php is invoked before mod_rewrite can have any effect. If this is the case, then make sure that php is loaded before mod_rewrite. Yes, that is "before" -- On Apache 1xx, modules are executed in reverse order from the load list. On Apache 2xx, this is not a problem because module priority is handled seperately from load order.

Jim

editordude

7:06 am on May 3, 2005 (gmt 0)

10+ Year Member



Well I've verified that all is working.
I've read the post, not learnt anything new from it and am still as stuck. :( Any other suggestions on where I can be told?

This for example should do the trick:

RewriteEngine on

RewriteRule ^(.*)/(.*)$ view.php?$1=$2

But I'm just getting an Internal Server Error

jdMorgan

2:29 pm on May 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> If it doesn't work, see your server error log -- it often gives very good information about the problem.

Post the relevant line(s) from your error log for the 500-Server Error for help with interpreting it.

Jim

editordude

5:45 pm on May 3, 2005 (gmt 0)

10+ Year Member



Finally managed it with this:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /lyrics
RewriteRule ^(.*)_(.*)$ $1\ $2 [S=1]
RewriteCond %{SCRIPT_FILENAME}!^.*view.php
RewriteRule ^(.*)/$ view.php?song=$1 [L]

Doubt I'll get a response for this but am needing help with 'conical'(sp?) urls where I have an add-on domain which I want to be the exlusive url for a subdirectory. So although the add-on domain wil load the right page, I don't want links from there to use the main server url and want it to continue using the add-on domain ..

any idea of how this would be done?