Hello! i didnt see any primary forum this should be in, so i'll ask the animals of PHP.
I really want the url
to be
Anyone got any idea? i've been searching and trying all day, but my brain capacity is not online today..
I will hug you...:(
Hello! i didnt see any primary forum this should be in, so i'll ask the animals of PHP.
I really want the url
to be
Anyone got any idea? i've been searching and trying all day, but my brain capacity is not online today..
I will hug you...:(
— the goal (turning index.php?page=images into /index/images) is simple; was on the right track but the suggestion had a small syntax issue and missed a few practical points (context, trailing slash, preserving extra query data, and avoiding redirect loops). Below is a concise, working .htaccess approach and a short checklist to make it reliable.
RewriteEngine On
RewriteBase /
# internal rewrite: /index/images -> index.php?page=images
RewriteRule ^index/([^/]+)/?$ index.php?page=$1 [L,QSA]
# optional: redirect old query URLs to clean URLs (use 302 for testing, then 301)
RewriteCond %{THE_REQUEST} \s/index\.php\?page=([^&\s]+) [NC]
RewriteRule ^ /index/%1? [R=302,L] Notes and troubleshooting:
.htaccess. In per-directory context the pattern must not start with a slash; the substitution for the internal rewrite should be index.php... (no leading slash).QSA keeps any extra GET parameters. The THE_REQUEST + redirect pattern ensures only browser requests for the old query form get redirected (prevents redirect loops after the internal rewrite).mod_rewrite is enabled (try apache2ctl -M or apachectl -M and grep for rewrite) and that Apache allows .htaccess (AllowOverride All for your document root).R=302 first, watch Apache error/access logs, and switch to R=301 when happy. On shared hosts, check with support if rewrites appear blocked.If the site uses a router or CMS that inspects REQUEST_URI, adapt patterns accordingly (for example accept other slugs or deeper paths). This should get the clean /index/images URLs working reliably.
if you have time, site point have an article on url rewriting
That article didnt tell me anything tho.. but to hell with it, i cant understand htaccess so i'll just keep it as it is
RewriteEngine On
RewriteRule ^index/([^/]*)\$ /index.php?page=$1 [L] htaccess
I think that may do it.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.