This is the first time I have ever tried to use mod_rewrite and have been stuck for a couple days. I am trying to change
to
Is this even achievable? Any advice will be very much appreciated!
This is the first time I have ever tried to use mod_rewrite and have been stuck for a couple days. I am trying to change
to
Is this even achievable? Any advice will be very much appreciated!
Short summary and practical fix for the thread: turning
/www.mysite.com/example6.php?id=games
into
/www.mysite.com/example6/games
is straightforward with mod_rewrite. As showed the existing query URLs and as suggested, the important bits are (a) where the .htaccess lives, (b) that mod_rewrite is actually honored by Apache (AllowOverride), and (c) avoiding side effects like MultiViews.
Example rules (two common placements)
# placed in the site root
Options -MultiViews
RewriteEngine On
RewriteBase / RewriteCond %{REQUESTURI} ^/example6/([A-Za-z0-9-]+)/?$
RewriteRule .* /example6.php?id=%1 [L,QSA,NC]
- .htaccess inside the example6 directory — pattern is relative to that folder:
```apache
# placed in /example6/.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /example6/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9_-]+)/?$ example6.php?id=$1 [L,QSA,NC] Quick troubleshooting checklist (common causes found in hosts and shared setups)
If legacy query URLs should redirect to the pretty form (SEO-friendly canonicalization), add a rule that detects requests for example6.php?id=... and issues an external redirect to /example6/<id> (use a 302 while testing, then 301). This approach avoids changing example6.php logic while presenting clean URLs.
Jump to Post— somedude3488 228RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^example6/([^/]+)$ example6.php?id=$1 [L]Does that work? Haven't tested it so I might of forgotten something. Just wrote it from memory.
I have searched this forum and have done extensive google search and have not been able to figure it out. I have many links that look like:
I have tried lots of different code putting this in my .htaccess file:
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /example6.php?id=$1 [L] and
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^id/(.*) example6.php?id=$1
</IfModule> and many more attempts but nothing works to get my URLS to look like this:
I do have mod_rewrite enabled on my server. Does anyone have any ideas? Thanks in advance.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^example6/([^/]+)$ example6.php?id=$1 [L] Does that work? Haven't tested it so I might of forgotten something. Just wrote it from memory.
No, I have also tried
RewriteRule ^(.*?)/(.*) example6.php?id=$1&id2=$2 and
RewriteRule ^example6/(.*)$ /example6.php?id=$1 [L] Does it matter where I upload my .htaccess file to? Thanks much
I would say just putting it in the document root would be ideal.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.