ryanfilard Posted June 14, 2011 Share Posted June 14, 2011 How do I make a php script that will use mydomain.com/username instead of mydomain.com/?p=username Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/ Share on other sites More sharing options...
HenryC Posted June 14, 2011 Share Posted June 14, 2011 Look up on mod_rewrite there is some good topics on here about it. Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229783 Share on other sites More sharing options...
RussellReal Posted June 14, 2011 Share Posted June 14, 2011 RewriteRule ^\/(.*)\/(.*)\/.*$ user.php?u=$1&interface=$2 example url: mydomain.com/russellreal/pm/ Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229798 Share on other sites More sharing options...
ryanfilard Posted June 15, 2011 Author Share Posted June 15, 2011 I put RewriteRule ^\/(.*)\/(.*)\/.*$ user/index.php?p=$1&interface=$2 in my ht access file. www.ryanweekly.com/cja to www.ryanweekly.com/user/?p=cja Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229808 Share on other sites More sharing options...
btherl Posted June 15, 2011 Share Posted June 15, 2011 Did it work? You might also need to switch on the rewrite engine with this line, before the rewrite rule: RewriteEngine On Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229830 Share on other sites More sharing options...
ryanfilard Posted June 15, 2011 Author Share Posted June 15, 2011 It did not this is my whole ht file: # 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 RewriteCond %{HTTP_HOST} ^ryanweekly.ryanweekly.com$ [OR] RewriteCond %{HTTP_HOST} ^www.ryanweekly.ryanweekly.com$ RewriteEngine On RewriteRule ^\/(.*)\/(.*)\/.*$ user/index.php?p=$1 Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229832 Share on other sites More sharing options...
btherl Posted June 15, 2011 Share Posted June 15, 2011 Those earlier rules may be interfering with the later rule. '-d' (is directory) Treats the TestString as a pathname and tests if it exists and is a directory. '-f' (is regular file) Treats the TestString as a pathname and tests if it exists and is a regular file. Anything which doesn't exist as a file or directory is getting rewritten to ./index.php by the WordPress rules. You can try putting your rules first: RewriteEngine On RewriteRule ^\/(.*)\/(.*)\/.*$ user/index.php?p=$1 # 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 RewriteCond %{HTTP_HOST} ^ryanweekly.ryanweekly.com$ [OR] RewriteCond %{HTTP_HOST} ^www.ryanweekly.ryanweekly.com$ I have no idea if that will work as rewrite rules can be quite arcane, but it's worth a try. Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229836 Share on other sites More sharing options...
ryanfilard Posted June 15, 2011 Author Share Posted June 15, 2011 It still won't do it. I dont know what I am doing wrong. Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229841 Share on other sites More sharing options...
btherl Posted June 15, 2011 Share Posted June 15, 2011 I think you'll need to use the debugging features of rewrite rules, as mentioned here: http://blog.logeek.fr/2007/12/31/how-to-debug-rewrite-rules-with-apache Basically it'll create a log telling you how it interpreted your rewrite rules. By looking at that log you can get an idea of what needs changing. Link to comment https://forums.phpfreaks.com/topic/239374-username-instead-of-pusername/#findComment-1229845 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.