Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-08-2012, 09:39 AM   PM User | #1
UD2006
Regular Coder

 
Join Date: Jul 2007
Location: Velsen Noord, Netherlands
Posts: 206
Thanks: 6
Thanked 0 Times in 0 Posts
UD2006 is an unknown quantity at this point
rewriterule on subdomain doesn't work

I have tried several combinations (searched from google), but none are working, I also add "RewriteEngine on" to the .htaccess, just as my hosting company told me.

I have this following url:

Code:
http://submain.domain/folder of url/index.php?page=$1
$1 can stand for Home, about, contact

The .htaccess code I use is this:
Code:
RewriteEngine on
RewriteRule ^page/?$ http://submain.domain/folder of url/index.php?page=$1 [L]
Nothing happends.
But it needs to be:
http://submain.domain/page/any of the mainpages


Another thing is that I also have "depth" pages:
Then the rewriten url needs to be:
http://submain.domain/Offerte/offert...dracht/another item

How can I do that?
UD2006 is offline   Reply With Quote
Old 04-10-2012, 03:46 AM   PM User | #2
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
Important Note: This fix is assuming your .htaccess is in the subdomain (ie: http://subdomain.domain/.htacess). If not, please clarify this.

You appear to be invoking the regex improperly. Try something like this:

Code:
RewriteEngine on
RewriteRule ^page/([A-Za-z]*)$ http://subdomain.domain/folder_of_url/index.php?page=$1 [L]
This will cause all requests to:

http://subdomain.domain/page/<insert alphabetic page>

to query

http://subdomain.domain/folder_of_url/index.php?page=<insert alphabetic page>

Keep in mind that this ONLY covers alphabetical page names. If you include numbers or other characters it will have to be modified.

(Bonus Tip: You may want to use the QSA flag as well ([L,QSA]) if you want to automatically append query strings (i.e: http://...../page/my_page?query=string))

For more clarification on how this is done, check out this tutorial.
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 04-10-2012, 02:40 PM   PM User | #3
UD2006
Regular Coder

 
Join Date: Jul 2007
Location: Velsen Noord, Netherlands
Posts: 206
Thanks: 6
Thanked 0 Times in 0 Posts
UD2006 is an unknown quantity at this point
The .htaccess is in the root of the subdomain.

I have tried, a couple of things you posted, even the tutorial but it didn't work.

The address remain the dynamic address, instead of the more friendly url.
UD2006 is offline   Reply With Quote
Old 04-10-2012, 05:25 PM   PM User | #4
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
Your phasing suggests that you might be expecting a redirect instead of a rewrite. The rewrite engine basically translates the clean URL into the dynamic URL for the purposes of the server.

Did you try navigating to the clean URL in your browser?
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 04-10-2012, 08:35 PM   PM User | #5
UD2006
Regular Coder

 
Join Date: Jul 2007
Location: Velsen Noord, Netherlands
Posts: 206
Thanks: 6
Thanked 0 Times in 0 Posts
UD2006 is an unknown quantity at this point
it's kinda working now, but the only thing, is that the url is now the friendly url, when I click on a menu item I get a message that the page isn't found, the url uses part of the friendly url but with the dynamic at the end.

Do I need to change the menu urls as well, because the menu of the website (links) are not working.
UD2006 is offline   Reply With Quote
Old 04-11-2012, 03:23 AM   PM User | #6
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
Then, as I detailed more at the end of this post, you'll want to add the QSA flag.

Change [L] to [L,QSA].
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Old 04-11-2012, 08:52 AM   PM User | #7
UD2006
Regular Coder

 
Join Date: Jul 2007
Location: Velsen Noord, Netherlands
Posts: 206
Thanks: 6
Thanked 0 Times in 0 Posts
UD2006 is an unknown quantity at this point
Quote:
Originally Posted by ShaneC View Post
Then, as I detailed more at the end of this post, you'll want to add the QSA flag.

Change [L] to [L,QSA].
I already did that, but the menu holds the following as link (displaying only the Home item, but there are more):

Code:
<a href="index.php?page=Home">Home</a>
I have seem a website that needs to change the menu href to => Home

and in the .htaccess create a rule for this:

Code:
RewriteRule ^Home$ http://subdomain.domain/Gratisofferte.nu/index.php?page=Home [L,QSA]
At the moment the cleanurl is as followed:

http://subdomain.domain/folder/page/Home

So when I click on a menu item (for example the home button), I get in the url:

http://subdomain.domain/folder/page/index.php?page=Home
UD2006 is offline   Reply With Quote
Old 04-11-2012, 05:31 PM   PM User | #8
ShaneC
Codeasaurus Rex


 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 659
Thanks: 31
Thanked 100 Times in 94 Posts
ShaneC is on a distinguished road
Well following the example we saw before you need to eliminate all of your dynamic URLs. Remember: Rewrite != Redirect.

So, this link:

Code:
<a href="index.php?page=Home">Home</a>
Needs to become this link:

Code:
<a href="page/Home">Home</a>
Keep in mind, though that this will not work with the rewrite rule I discussed earlier:
Code:
http://subdomain.domain/folder/page/Home
For that you'll need to modify ^page/([A-Za-z]*)$ to ^folder/page/([A-Za-z]*)$
__________________
Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
My posts, comments, code, and suggestions reflect only my personal views.
Web Portfolio and Code Snippets: http://shanechism.com
ShaneC is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:51 AM.


Advertisement
Log in to turn off these ads.