0

So I have been trying to get my url to look better, but I can not get it to work as I want, so there might be some nice soul here that can help me out.

I need help with

ex: www.domain.com/project/index.php?p=settings&u=123&l=k

To look like www.domain.com/project/settings

I want index.php to be removed and all that comes after the first variable, in this case, p=settings, and also remove ?p=

I got this now

    RewriteEngine On
    RewriteBase /

    # Removes index.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
    RewriteCond %{REQUEST_URI} !/system/.* [NC]
    RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

    # Directs all EE web requests through the site index file
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
MrUnknown
  • 13
  • 6
  • possible duplicate of [Reference: mod\_rewrite, URL rewriting and "pretty links" explained](http://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained) – deceze Feb 14 '14 at 13:34

3 Answers3

0

Give this a whirl.

RewriteRule ^project/([^/]*)$ /project/index.php?p=$1&u=123&l=k [L, QSA]
ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49
  • But that dose only work if the u variable=123 and l variabele = k Those variables are just example, is there a way to just remove what ever come there? Cause I got a bunch of other variables more. Or could I just put a wildcard * after $1 ? – MrUnknown Feb 14 '14 at 13:36
0

There is the Possibility to redirect errorcodes

ErrorDocument 404 /index.php

In this way you can ask for www.domain.com/project/settings witch does not exist and instead of the error 404 you get redirected to /index.php

$uri_asked = explode("/", $_SERVER['PHP_SELF']);

then you have

$uri_asked[3]="project";
$uri_asked[4]="settings";

and you can build something like

include("www.domain.com/index.php?p=".$uri_asked[3]."&u=".$uri_asked[4]);
0

You can use this rule to discard unwanted query string:

RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php\?p=([^&\s]+) [NC]
RewriteCond %{REQUEST_URI} !/system/ [NC]
RewriteRule ^(.*?)index\.php$ /$1%1? [R=301,NE,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643