Reputation: 21
pls, help me to resolve this issues, we are facing this problem from last couple of days.
I have a problem with my .htaccess
I have set my $base_url = http://localhost/example.com/
Like this
I have a URL that looks like:
http://localhost/example.com/test.php?id=10
I want to convert this url like this :
http://localhost/example.com/10
Here is my .Htaccess
code
RewriteEngine On
<ifModule mod_headers.c>
Header set Connection keep-alive
</ifModule>
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
#AddOutputFilterByType DEFLATE text/plain
#AddOutputFilterByType DEFLATE text/html
#AddOutputFilterByType DEFLATE text/xml
#AddOutputFilterByType DEFLATE text/css
#AddOutputFilterByType DEFLATE application/xml
#AddOutputFilterByType DEFLATE application/xhtml+xml
#AddOutputFilterByType DEFLATE application/rss+xml
#AddOutputFilterByType DEFLATE application/javascript
#AddOutputFilterByType DEFLATE application/x-javascript
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^\.]+)$ $1.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)/?$ $0.php [NC,L]
RewriteRule ^user/profile/([A-Za-z0-9-\s&/()+']+) user-profile-edit.php?name=$1 [NC,B,L]
RewriteRule ^user/profile user-profile.php [NC,B,L]
RewriteRule ^user/dashboard user-dashboard.php [NC,B,L]
RewriteRule ^user/address user-addresses.php [NC,B,L]
RewriteRule ^user/add-address user-address-add.php [NC,B,L]
RewriteRule ^user/booking user-booking.php [NC,B,L]
# Condition For Test Page
RewriteCond %{QUERY_STRING} (^|&)id=\$1($|&)
RewriteRule ^tests\.php$ /$1?&%[R=301,L]
So How to fix this problem?
Upvotes: 2
Views: 90
Reputation: 785146
Inside example.com/.htaccess
you may try these rules:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+([^/]+)/test\.php\?id=([\w-]+)\sHTTP [NC]
RewriteRule ^ /%1/%2? [R=302,L,NE]
RewriteRule ^user/profile/([-\w\s&/()+']+)/?$ user-profile-edit.php?name=$1 [NC,QSA,L]
RewriteRule ^user/profile/?$ user-profile.php [NC,L]
RewriteRule ^user/dashboard/?$ user-dashboard.php [NC,L]
RewriteRule ^user/address/?$ user-addresses.php [NC,L]
RewriteRule ^user/add-address user-address-add.php [NC,L]
RewriteRule ^user/booking/?$ user-booking.php [NC,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteRule ^([\w-]+)/?$ test.php?id=$1 [QSA,L]
Upvotes: 1