Jump to content
MakeWebGames

Apache is hard!


POG1

Recommended Posts

Apache is a tricky one! I have read a lot on this and i am still stumped. I can write some simple rewrite expressions but i am stuck still. What i have you put in the page but it will only be a single directory url. This is the code i have.

RewriteEngine on

#RewriteRule ^/([A-Za-z0-9-]+)/?$ index.php?page=$1 [L]

That code will allow me to have URLs such as

/armybase?page=buyTanks&buy=2

But how could i have a totally friendly url? With a URL like this; /armybase.php?page=buyTanks&buy=2

I want to change it to something like this; /armybase/buy-tanks/2

The website will have about 12 main pages, would there be an easy way to add all these? :S

 

I have found this code from a social networking engine, it has nice URLs but the code is foreign to me.

 

RewriteEngine On



RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>file/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>install/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>design/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>plugins/.*

RewriteRule ^index.php(/.*)$ <%SUBFOLDER%>index.php?do=$1 [L]



RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>file/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>install/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>design/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>plugins/.*

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>index.php

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>robots.txt

RewriteCond %{REQUEST_URI} !^<%SUBFOLDER%>favicon.ico

RewriteRule ^(.*)$ <%SUBFOLDER%>index.php?do=/$1 [L]
Link to comment
Share on other sites

Re: Apache is hard!

You could use the <base> element.

<base href="http://www.yoursite.com" />

and when you the following path:

"images/image1.png"

it goes to http://www.yoursite.com/images/image1.png

+about the rewrite stuff these are examples I use:

RewriteRule ^bank/([^/]*)$ /bank.php?error=$1 [NC]

RewriteRule ^train/([^/]*)$ /train.php?error=$1 [NC]

RewriteRule ^mail/([^/]*)/([^/]*)/([^/]*)$ /mail.php?action=$1&ID=$2&subject=$3 [NC]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...