Rewrite URL's in Joomla menus - mod-rewrite

My group and I are working on a school project with Joomla. We have custom php to list "articles" from our database, and the PHP is getting its data from $_GET (from the url.)
Skip to the question:
This is what we have:
example.com/articles/menu
We want:
example.com/articles/menu?q=something+something
How do you rewrite / add text to url, so we get that format?
We are using the school server, so we have no admin-rights on the server.
I have tried mod_rewrite rules in .htaccess, but without success.
The server is running windows.
We are using joomla 2.5
RewriteEngine On
RewriteRule ^index.php/articles/menu?q=something+something$ /index.php/articles/menu [L]

Try this:
RewriteEngine On
RewriteRule ^/articles/menu$ index.php/articles/menu?q=something+something [QSA,L]
And that will do the job.
Hey by the way, try to google a bit, there are tons of answers for such simple things ;)
Checkout the right documentation about QSA directive: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa

Related

Codeigniter HMVC without 'index.php'

I implemented the wiredesignz HVMC functionality in CI 2.1.7.
The only problem, is that, unlike the tutorial I followed(http://somethingstatic.com/setting-hmvc-codeigniter-2-1/), I have to add 'index.php' in my url:
how it should be according to the tutorial:
http://localhost/site/hmvc
What I actually have to call:
http://localhost/site/index.php/hmvc
How can I configure CI so the 'index.php' is not needed?
You need not to do anything extra. this link will help you to get this thing done. Just normal procedure. I done multiple times with the same one.
Hope this helps you.
//user following code in your .htaccess file to remove index.php from url.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]

ModRewrite .htaccess / SEO URLs syntax

I am trying to re-use some .htaccess code on a new site/server and it doesn't work correctly. I'm not an expert with URL rewriting so would appreciate it if anyone can see if my syntax is incorrect or if there is something else I need to check server side.
I am using the following code:
Options +FollowSymLinks
RewriteEngine on
# News Pages
RewriteRule ^news/$ /news.php
RewriteRule ^news/(.*?)/$ /news.php?article=$1
It works for the 1st level, /news/ but /news/article-1/ just loads the /news/ (news.php) overview page. /news.php?article=article-1 works correctly.
Server is running Apache 2.2.9 and PHP is in CGI mode.
Try it such way:
RewriteRule ^news/(.*?)/?$ /news.php?article=$1 [L]
RewriteRule ^news/?$ /news.php [L]
[L] in the end of instruction stops server cheacking of other instructions, if current one match.
So you write more specific ahead of more general.
If your rules work correctly being the only one in the .htaccess, then such organisation of them can help.
/? - this means that / at the end can absent or present

Using mod_rewrite or htaccess to apply 301's to entire site structure, with URL's built using query strings

I am taking over an old website, and need to change the domain name.
The current domain is http://www.example.com/folder/ and the new domain is http://example.school.nz
An example of an existing and desired URL is:
Before: http://www.example.com/folder/index.php?page=sport
Desired: http://example.school.nz/about-us/sport
The site is built using CMSMS (http://www.cmsmadesimple.org), so pages and URL's are generated through the CMS, although it's easy enough to export a list of URL's.
Ideally I could set up 301 redirects for the entire site so the user doesn't get 404'd. Any clues to the easiest way to accomplish this?
It depends on how general you want things to be, but this set of rules will do what you asked in your question:
RewriteCond %{HTTP_HOST} .*
RewriteCond %{QUERY_STRING} page=sport
RewriteRule ^folder/index.php http://example.school.nz/about-us/sport? [L,R=301]

Code Igniter URL routing confusion

I have a slight issue. I have configured my default controller as :
c$route['default_controller'] = 'news';
so when I point my browser to http://localhost/mysite all the news get loaded as instructed by the news controller.
Now on this page, I have given links to "read article" to read the full article. For this I have to point my browser to http://localhost/index.php/news/view/news-slug. I want to remove index.php from the url. I had already tried re-routing using wildcard without any success. Can you tell me how to do that?
There is a documentation on removing the index.php from the URL if you are using Apache with it's mod_rewrite:
Removing the index.php file
Using the following rewrite code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also, there are many similar questions to yours, have a look at these questions from the search:
Search query on removing index.php in Codeigniter
You need to define your .htaccess file for this. Check this wiki: http://codeigniter.com/wiki/mod_rewrite

Rewriting a Subdomain with mod-rewrite

I have a project that uses the moodle library. I had to change the URL from moodle.example.com to learn.example.com, due to a client request.
I thought this would be an easy change, but alas moodle inserts all links and images in with the complete url instead of the relative url.
Is it possible using mod-rewrite to point all requests to moodle.example.com to learn.example.com and maintain the query string?
Example:
I want a request to: http://moodle.example.com/course/view.php?id=2&topic=1 to go to http://learn.example.com/course/view.php?id=2&topic=1.
Is this possible?
Thanks,
Josh
Try this rule:
RewriteCond %{HTTP_HOST} =moodle.example.com [NC]
RewriteRule ^ http://learn.example.com%{REQUEST_URI} [L,R=301]
In addition to the apache rewrite rules, it may also be worth looking at the moodle documentation on migration: http://docs.moodle.org/en/Moodle_migration
In particular look out for admin/replace.php. This tool can help you to rewrite links across all text in the moodle database at the same time.

Resources