DingDong Posted July 13, 2010 Share Posted July 13, 2010 I am uable to pass query string variables through pretty URL in my test site which has the ip with tilda username URL (example: http://00.00.00.000/~sitename/testpage/$id). Can it be due to server settings, or the tilda in the URL? Execution gives me a 404 error. The url is displayed on the page as <a href='http://00.00.00.000/~sitename/testpage/$id'>".$title."</a> The htaccess file is: <IfModule mod_rewrite.c> Options +Indexes Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d # RewriteCond %{REQUEST_FILENAME} !-f # RewriteRule ^testitemnews/(.*)\$ test.php?id=$1 [QSA,L] </IfModule> I also tried the rewrite rule with # RewriteRule ^http://00.00.00.000/~sitename/testitemnews/(.*)\$ http://00.00.00.000/~sitename/testpage.php&id=$1 [QSA,L] Why is the page not displaying? I am really in a bad situation. Please help. The page displays if the url is not pretty with no htaccess code. What server setting should be changed or is it the code? The php server is 5.9 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/207603-htaccess-not-working-with-~username-url-please-help/ Share on other sites More sharing options...
cags Posted July 13, 2010 Share Posted July 13, 2010 The first part of a RewriteRule matches against the REQUEST_URI, not the full path so the second example is definitely incorrect. As for your first example, this would assume that the .htaccess file is in the /~sitename/ folder. I'm also not clear on why you have the forward slash before the dollar. My best guess at what you're after is... RewriteRule ^testitemnews/(.*)$ /~sitename/test.php?id=$1 [QSA,L] Quote Link to comment https://forums.phpfreaks.com/topic/207603-htaccess-not-working-with-~username-url-please-help/#findComment-1085405 Share on other sites More sharing options...
DingDong Posted July 13, 2010 Author Share Posted July 13, 2010 I removed the slash and tried the code. It is still giving me 404 error. My code was working perfectly fine in a shared server and I want to migrate to different one. This hosting company says if I add extension to the file, it works. eg: RewriteRule ^test.php/(.*)$ test.php?id=$1 [QSA,L] It does work. But I want clean url and they are unable to help me as I do not what server setting is wrong or to be turned on. Any help? Quote Link to comment https://forums.phpfreaks.com/topic/207603-htaccess-not-working-with-~username-url-please-help/#findComment-1085417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.