Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple mod_rewrite rules
    primarykey
    data
    text
    <p>I have successfully created my mod_rewrite rule to change all dynamic URLs on the top level of the site, but now i need to create a rule for a second level, and i think later down the line i might need a second, second level of rewrites. </p> <p>At the moment i have this </p> <pre><code> RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?subj=$1 </code></pre> <p>And this helps to change /index.php?subj=home to /home as iut does for all other pages such as /contact /about /events and so on. </p> <p>But now I have created sub pages under events and therefore need to change /events.php?event=event-name to /event-name. But when i add another rule it messes up the whole site. What i tried to do is this </p> <pre><code> RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?subj=$1 RewriteRule ^(.+)$ event.php?event=$1 </code></pre> <p>But that didnt work. </p> <p>But on top of all that i want to redirect index.php and / (the root) to /home </p> <p>Could anyone please show me the correct rules as I have searched around but I just can't seem to get it right.</p> <p>Many thanks in advance :) </p> <p>Cheers</p> <p>UPDATE: Thanks for all your help so far, ive tried everything but can't seem to get it right. As suggested by Ben I will give a bit more info on the URLs. Right now the entire site is sitting in a sub-directory as for now its still under development, so for now it is in mydomain.com/newwebsite/event.phpevent=2 But the .htaccess file currently in the root folder of the development site so it is in /newwebsite directory. So the URL that i am trying to write would be mydomain.com/newwebsite/event/2</p> <p>You notice it says '2' and that is simply the page/event id. further down the line it will not be the id but rather its title.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload