php - Using mod_rewrite to make a url prettier -


i trying use mod_rewrite change appearance of url's. lost in , use help. first of all, possible use mod_rewrite alter "front-end" of url , keep same internally? if so, how following:

i have https://domain.com/live/page.php?id=x both "page" , "x" being variable, , url's shown https://domain.com/page if possible, or if need id=x in there https://domain.com/page/x/ don't know if need have id somewhere in url.

please me know common thing can't figure out!

thanks!

edit: of anubhava got working halfway. time put code .htaccess /live/ directory not root one. pages change url correctly, still need server load original new url's giving me 404. here code:

rewriteengine on  rewriteoptions inherit  rewritecond %{the_request} \s/+live/([^.]+)\.php\?([^=]+)=([^\s&]+) [nc] rewriterule ^ /%1/%2/%3? [r=302,l]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /live/$1.php?$2=$3 [l,qsa,nc] 

edit: here current .htaccess files

root:

rewriteengine on  rewriteoptions inherit  rewritecond %{http_host} ^bidwaffle\.com$ [or] rewritecond %{http_host} ^www\.bidwaffle\.com$  rewriterule ^/?$ "https\:\/\/bidwaffle\.com\/live" [r=301,l] 

and in root\live\:

# secure htaccess file <files .htaccess>  order allow,deny  deny </files>  # disable directory browsing options -indexes  # disable access logs/template files <files ~ "\.(log|tpl)$">  order allow,deny  deny </files>  rewritecond %{the_request} \s/+live/([^.]+)\.php\?([^=]+)=([^\s&]+) [nc] rewriterule ^ /%1/%2/%3? [r=302,l]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /live/$1.php?$2=$3 [l,qsa,nc] 

the url changes doesn't load (silent loading of real url). right see issue of second part may not see request because /live/ no longer in "pretty url" /live/.htaccess might not called. tried putting part root/.htaccess , did same weird thing appending referring page instead of %3

yes sure can have rules in document_root/live/.htaccess file:

rewriteengine on rewritebase /live/  rewritecond %{the_request} /([^.]+)\.php\?([^=]+)=([^\s&]+) [nc] rewriterule ^ /%1/%2/%3? [r=302,l] 

root .htaccess:

rewriteengine on  rewritecond %{http_host} ^(www\.)?bidwaffle\.com$ rewriterule ^/?$ https://bidwaffle.com/live/ [r=301,l]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/]+)/([^/]+)/([^/]+)/?$ /live/$1.php?$2=$3 [l,qsa,nc] 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -