Forum Moderators: phranque
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The new custom rule i'd like to make is whenever there's a get variable like: www.mysite.com/?profile=username
I want to make it look like: www.mysite.com/username
www.example.com/username the rewrite alters the internal pointer to instead silently fetch conetent from /index.php?profile=username. example.com/index.php?profile=username or example.com/?profile=username they are redirected to www.example.com/username. This rule goes at the top of the .htaccess file.
<IfModule mod_rewrite.c> RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteRule ^index\.php$ - [L] skips rewriting if the request (either externally or internally) was for /index.php. This is the same as adding RewriteCond %{REQUEST_URI} !^/index.php to the following ruleset. It prevents an infinite loop (actually, the -f and -d checks also do that, so in fact this "pre-check" for index.php stops the very slow and unwanted -f and -d checks running after the rewrite has completed, i.e. in the next pass through of the .htaccess file for the current request). RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] - this is the main rewrite to serve the content. It's not "single character". As the pattern is unanchored, it is "one or more". You could say .+ but the + isn't needed.
# BEGIN WordPress
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule ^/([^/]+)$ ?profile=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /verlete/index.php [L]
# END WordPress
RewriteRule ^/([^/]+)$ ?profile=$1 [L]
RewriteRule ^/([^/]+)$ ?profile=$1 [L] RewriteRule ^([^/.]+)$ /index.php?profile=$1 [L] This is the .htaccess:
# BEGIN WordPress
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule ^([^/.]+)$ ?profile=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# BEGIN WordPress
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule ^([^/.]+)$ index.php/?profile=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
myurl.com/username/
^([^/.]+)$ - requested path must not contain any slashes or periods - example.com/username/ and example.com/profile/username will not match! You'll need ^profile/([^/.]+)$ here. index.php/?profile=$1 - is looking for an index.php file inside a folder also called index.php - the slash is in the wrong place. You'll need /index.php?profile=$1 here.
# BEGIN WordPress
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule ^([^/.]+)$ /index.php?profile=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
mysite.com/username/
do you mean the username? cause they definately are letters and numbers only
^([^/.]+)$ - pattern says "requested path must not contain any slashes or periods". example.com/username would match, but I really do advise you have usernames in a /profile/ folder.