i want a change the htaccess rule to hide the url expression from user.i am searching to much on google but not get solution. my website links like this
http://www.psreducators.com/agent-profile/?u=mark-paul
but i want to like this
http://www.psreducators.com/agent-profile/mark-paul
hide this ?u= from the visiter or a user
agent-profile is not a directory it is a page name in wordpress and
next is the user name mark-paul i want a hide only ?u= in this url
agent-profile show in url but actual page name is template_agent_profile.php
# This file is - if you set up HUGE correctly - not needed.
# But, for fallback reasons (if you don't route your vhost to /public), it will stay here.
RewriteEngine on
RewriteRule ^(.*) public/$1 [L]
# Everything from is for browser caching and is totally optional
# Deflate Compression by FileType
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>
# Set browser caching to 1 month
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<ifmodule mod_headers.c>
<filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesmatch>
<filesmatch "\\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesmatch>
<filesmatch "\\.(js)$">
Header set Cache-Control "max-age=216000, private"
</filesmatch>
</ifmodule>
Seems like you have a folder structure like this:
root directory
dkeknth
index.php
agent-profile
index.php
derrjjfv
index.php
....
if this is the case, you can put a .htaccess file in each folder, where you want to prettify the url and put these lines in .htaccess file:
RewriteEngine on
RewriteRule ^([a-f0-9]+)$ index.php?u=$1 [QSA]
In index.php file you can get the value like
if(isset($_GET['u'])){
/*what you want to do*/
}
Where you have url like ...index.php?id=1; just replace the u
with id
Now you can access the urls like
http://www.psreducators.com/agent-profile/mark-paul
http://www.psreducators.com/dkeknth/1
http://www.psreducators.com/derrjjfv/1
...
you can also place a single .htaccess file in root directory like this
RewriteEngine on
RewriteRule ^([a-f0-9]+)/agent-profile$ agent-profile/index.php?u=$1 [QSA]
RewriteRule ^([a-f0-9]+)/dkeknth$ dkeknth/index.php?id=$1 [QSA]
RewriteRule ^([a-f0-9]+)/derrjjfv$ derrjjfv/index.php?id=$1 [QSA]
...
Try :
RewriteEngine On
RewriteCond %{THE_REQUEST} /agent-profile/\?u=([^\s]+) [NC]
RewriteRule ^ /agent-profile/%1 [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^agent-profile/([^/]+)/?$ /agent-profile/?u=$1 [NC,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.