My .htaccess is in test and I have added the folowing commands.
Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^Categorie/([^.]+)$ test/index.php?p=$1 [L]
If I check p in the index whit the url domain.com/test/Categorie/1
I get demo1.
If I do domain.com/test/Categorie/1/somename/
I get a 404 error.
Everywhere on the internet I find this solution for my problem but stangly enough I can not get it working because I keep getting this problem.
RewriteRule ^c([0-9]+).*\.html test/index.php?c=$1
is what I used to fix it.
Related
I need to change the pattern of my url from the normal path into a subdomain. I tried write the .htaccess but it's not work.
http://hello.com/sos/article.php?id=1&title=this-is-a-title.php
From the url above I want to:
Change the pattern to call the page so I remove sos before the domain as a subdomain. So I'd got http://sos.hello.com/
I need the variable to be replaced with forward slash and suffixed with .sos. As the story is about warning : article/1/this-is-a-title.sos
I wish I could have something like this:
http://sos.hello.com/article/1/this-is-a-title.sos
So I wrote :
RewriteEngine On
RewriteRule ^article/([^/]*)/([^/]*)\.sos$ /article.php?id=$1&title=$2 [L]
And guess what! It's not work. Please point me out. What I've done wrong???
I've got the answer after several tries:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.hello.com
RedirectMatch 301 ^/sos/$ http://sos.hello.com/mypage.php
RewriteRule ^article/([^/]*)/([^/]*)\.sos$ /article.php?id=$1&title=$2 [L]
save as .htaccess to the subdomain directory
I am currently having an issue using the URL manager and/or the apache mod_rewrite or maybe something else entirely.
With showScriptName set to false, navigating to addresses such as domain.com/login, domain.com/logout, domain.com/site/login are all behaving the same way. It simply shows the main site/index, as if I were to navigate to domain.com/eeofjew9j8jfdedfmewf (jibberish).
Maybe it's an issue with my Yii settings? Here are those (sorry for the sloppiness):
'components'=>array(
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'login'=>'site/login',
'logout'=>'site/logout',
'register'=>'users/register'
),
,...
Here is how I have my .htaccess setup in the www root:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
I am using a VPS server, so I have root access to make any changes needed to apache. I've checked my phpinfo and mod_rewrite is running and enabled. In my apache config, I have for my www directory:
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
I've been scratching my head on this issue through 3 different hosts (godaddy, dreamhost, and lithiumhosting) so I'm assuming it's an issue on my end with this. Now that I have a VPS though, I'm hoping I can finally figure out my issue and solve it.
First verify that the server is parsing the .htaccess file. This is simply done by placing random text in the .htaccess file such as
CREATE AN ERROR
If this gives you a server error then the file is being parsed. You may have to move the .htaccess file up a directory to get this to work.
After this is working check to make sure the rewrite module in Apache is on. First check phpinfo and look for the running module. If not you may have to delete the comment (#) character in front of the module.
After the module shows up in phpinfo then see if you can do a basic rewrite to make sure that there are not problems with Apache.
RewriteEngine on
RewriteRule ^ http://google.com/? [L,R]
If that is not working try adding the
Options +SymLinksIfOwnerMatch
to the file
Once you have Apache doing it's part now it is up to yii. This code:
RewriteEngine On
RewriteBase /mybasedirectory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA]
adds the rewrite base option which may be necessary if you do not have the files in the document root such as htdocs
finally if that does not solve the problem then limit your rule to a simple rule such as
'contact'=>'site/contact',
and see if at least redirects to where you think it should. Of course you may have to check the basic rules of .htaccess again to make sure that overide is allowed and there isn't an errant .htaccess in a subdirectory. I hope that helps. I finally got mine working.
What happens if you delete these lines!
enter code here
# otherwise forward it to index.php
RewriteRule . index.php
if you add this code see if it works
'<action:(login|logout|register|contact)>' => 'site/<action>',
I'm learning how to mod rewrite URLs and I encountered a 500 server error after having this .htaccess file in my root folder:
RewriteEngine On
RewriteRule ^([^/]*)$ /a.php?a=$1 [L]
It would be great if someone can tell me which part I got wrong, thanks
Include at least all basic directives and one condition to prevent loops. Like this:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
# Prevent loops
RewriteCond %{REQUEST_URI} !a\.php [NC]
RewriteRule ^([^/]*)/? a.php?a=$1 [L]
Maybe that's what you need, although I did not test it because it is impossible without a sample of the incoming URL, which is missing in the question.
I just transferred my local web app to my server, and now I'm getting this error:
Parse error: syntax error, unexpected
T_OBJECT_OPERATOR in
/nfs/c05/h01/mnt/71658/domains/ergo-metric.com/html/application/libraries/Survey_form_processing.php
on line 172
This is odd because it works locally! I changed my db settings to the production server, and my base_url is correct.
Any ideas what this could be?! I'm a little worried b/c this is a live site!
I would start with your php config file, check what is enabled on your end and what is enabled on the other end. but first check your config file and look for rewrite short open tags switch it to true. these are very basic but you didn't give a whole lot of information, maybe post a few lines of code before and after 172 let me see what is going on there. also if you are using htaccess files and are still using the default CI example i would switch it to this works like a charm: this is a universal htaccess file no matter your setup you dont have to change it promise you that the best thing since sliced bread.
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
i am going to be on for a while if you reply maybe we can get this worked out for you two heads are better than one thing you know
I have used rewrite url module but I am not able to redirect to the target page and
I am getting error as:
The requested URL /old.html was not found on this server.
Here is my code:
<IfModule mod_rewrite>
RewriteEngine On
RewriteRule ^old.html$ new.html [R]
</IfModule>
Is AllowOverride set to All in your httpd.conf? Like this:
AllowOverride All
Also, your .htaccess should inlcude the L modifier for the last rule, and if you really want to redirect permanently, R=301:
RewriteEngine On
RewriteRule ^old.html$ /new.html [R=301,L]
You need to escape the . in .html with a \
So its:
RewriteEngine on
RewriteRule ^old\.html$ new.html [R]
Try also setting the RewriteBase to / like so
RewriteBase /
I've also tried this code for
RewriteEngine On
RewriteBase /
RewriteRule ^old.html$ /new.html [R=301,L]
error as The requested URL /old.html was not found on this server.
How to check the load module in apache server?