Hello. I have no idea how, so i'll ask you.

I need /s/index.php?i=123

to be

/s/123

any direction or tips would be appreciated!

cheers,
Sorcher

Dani AI

Generated

Short answer: the approach suggested (an .htaccess rewrite) is the right way to expose /s/123 while serving s/index.php?i=123 — and confirmed it fixed the problem. A few practical points and troubleshooting tips that are not in the thread:

Where the .htaccess lives matters. Patterns in per-directory (.htaccess) context are matched against the path relative to that directory; if you put the file inside the /s/ folder your rules and substitutions behave differently than if the file is in the site root. If things seem to “not match”, check whether you need a base for relative substitutions. See Apache’s mod_rewrite notes for how per-directory processing works: mod_rewrite docs.

Make sure Apache actually honors .htaccess files for the directory (AllowOverride). On many servers a config change is required so .htaccess files are processed at all. If rewrites silently fail, check the directory’s AllowOverride setting and restart Apache after any changes: AllowOverride directive.

Quick debugging tips: enable higher rewrite logging via Apache’s LogLevel (look for the rewrite trace), test requests with curl or browser devtools to see whether the response is an internal rewrite (URL unchanged) or an external redirect, and watch for 500 errors in the error log. Common gotchas to avoid: accidentally rewriting real files (images, css), mismatches from trailing slashes, and whether you want the original query string preserved or explicitly overridden. For shared hosts without config access, a front-controller that parses PATH_INFO or REQUEST_URI in PHP is a simple fallback.

Recommended Answers

All 2 Replies

In .htaccess file create the code below :

RewriteEngine on
RewriteRule ^s/([0-9]*)/?$ s/index.php?i=$1 [L,QSA]

or

RewriteRule ^([0-9]*)/?$ index.php?i=$1 [L,QSA]

Remember if you use rewriterule using .htaccess in your local server (the case i'm use xampp), you must uncomment the line:
LoadModule rewrite_module modules/mod_ in file httpd.conf

for default it has # prefix
#LoadModule rewrite_module modules/mod_, just remove the #.

Find file named httpd.conf in folder "xampp -> apache -> conf".

thanks, helped allot!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.